diff --git a/canvas.py b/canvas.py index 84784ae..76bc4ea 100644 --- a/canvas.py +++ b/canvas.py @@ -21,10 +21,12 @@ class EditorCanvas(tkinter.Canvas): self.view_y=0 self.bind("",self.handle_draw) self.bind("",self.handle_draw) - self.bind("",self.handle_move_start) - self.bind("",self.handle_move) + self.bind("",self.handle_move_start) + self.bind("",self.handle_move) + self.bind("",self.handle_erase) + self.bind("",self.handle_erase) if platform.system()=="Windows" or platform.system()=="Darwin": - self.bind("",lambda event: self.handle_zoom(event.delta)) + self.bind("",lambda event: self.handle_zoom(event.delta/120)) else: # This will probably work only on X11 self.bind("",lambda _: self.handle_zoom(1)) @@ -76,6 +78,16 @@ class EditorCanvas(tkinter.Canvas): self.draw() + def handle_erase(self,event): + pixel_pos=self.cursor_pos_to_pixel((event.x,event.y)) + if not pixel_pos: + return + self.current_char_modified=True + self.project.modified=True + self.current_char_pixels[pixel_pos[0]*self.project.char_res[1]+pixel_pos[1]]=0 + self.draw() + + def handle_zoom(self,delta): self.grid_size+=delta self.width=self.project.char_res[0]*self.grid_size