mirror of
https://github.com/1j01/textual-paint.git
synced 2024-11-28 10:03:29 +03:00
Don't delete the whole textbox when pressing Delete
This commit is contained in:
parent
fe8c05bdc0
commit
ed5e399a58
@ -126,7 +126,7 @@ cat file.ans
|
||||
|
||||
## Known Issues
|
||||
|
||||
- Pressing Delete while using the Text tool deletes the whole text box. Similarly, Ctrl+A selects the canvas instead of the text in the text box.
|
||||
- Pressing Ctrl+A in textbox selects the canvas instead of the text in the text box.
|
||||
- Selection box border is inside instead of outside (and lacks dashes). For the text box, I hid the border because it was too visually confusing, but it should also have an outer border.
|
||||
- Pick Color can't be cancelled, since it samples the color continuously.
|
||||
- Pressing both mouse buttons to cancel tools can sometimes result the the tool restarting, or it's just my mouse. It's probably my mouse, now that I think about it. But also, it should actually undo current action, not just end it.
|
||||
|
16
paint.py
16
paint.py
@ -1169,8 +1169,7 @@ class PaintApp(App[None]):
|
||||
Binding("ctrl+w", "stretch_skew", _("Stretch/Skew")),
|
||||
Binding("ctrl+i", "invert_colors", _("Invert Colors")),
|
||||
Binding("ctrl+e", "attributes", _("Attributes")),
|
||||
# TODO: don't delete textbox with delete key
|
||||
Binding("delete", "clear_selection", _("Clear Selection")),
|
||||
Binding("delete", "clear_selection(True)", _("Clear Selection")),
|
||||
Binding("ctrl+a", "select_all", _("Select All")),
|
||||
Binding("ctrl+pageup", "normal_size", _("Normal Size")),
|
||||
Binding("ctrl+pagedown", "large_size", _("Large Size")),
|
||||
@ -2386,9 +2385,16 @@ class PaintApp(App[None]):
|
||||
"""Draw the selection onto the image and dissolve the selection."""
|
||||
self.meld_or_clear_selection(meld=True)
|
||||
|
||||
def action_clear_selection(self) -> None:
|
||||
"""Delete the selection and its contents."""
|
||||
self.meld_or_clear_selection(meld=False)
|
||||
def action_clear_selection(self, from_key_binding: bool = False) -> None:
|
||||
"""Delete the selection and its contents, or if using the Text tool, delete text."""
|
||||
sel = self.image.selection
|
||||
if sel is None:
|
||||
return
|
||||
if sel.textbox_mode:
|
||||
if not from_key_binding:
|
||||
self.on_key(events.Key("delete", None))
|
||||
else:
|
||||
self.meld_or_clear_selection(meld=False)
|
||||
|
||||
def on_canvas_tool_update(self, event: Canvas.ToolUpdate) -> None:
|
||||
"""Called when the user is drawing on the canvas.
|
||||
|
Loading…
Reference in New Issue
Block a user