mirror of
https://github.com/1j01/textual-paint.git
synced 2024-12-01 08:47:07 +03:00
Fix pasting into CharInput not affecting brush
This commit is contained in:
parent
2c1069d619
commit
85ba439cbd
@ -201,7 +201,6 @@ To preview ANSI art files in file managers like Nautilus, Thunar, Nemo, or Caja,
|
|||||||
- Hitting Enter in View Bitmap mode exits the mode but may also trigger a menu item. Menu items ought to be disabled when hidden, and View Bitmap should prevent the key event from taking other actions if possible.
|
- Hitting Enter in View Bitmap mode exits the mode but may also trigger a menu item. Menu items ought to be disabled when hidden, and View Bitmap should prevent the key event from taking other actions if possible.
|
||||||
- Airbrush is continuous in space instead of time. It should keep spraying while the mouse stays still.
|
- Airbrush is continuous in space instead of time. It should keep spraying while the mouse stays still.
|
||||||
- After setting a custom zoom level, the magnifier tool will not return to the custom zoom level when un-magnifying and re-magnifying.
|
- After setting a custom zoom level, the magnifier tool will not return to the custom zoom level when un-magnifying and re-magnifying.
|
||||||
- Pasting into the character input box of the color palette changes the displayed character but not the character used for drawing.
|
|
||||||
- Dragging and dropping files may fail if the character input box is focused. Click in the area around the canvas to remove focus.
|
- Dragging and dropping files may fail if the character input box is focused. Click in the area around the canvas to remove focus.
|
||||||
|
|
||||||
The program has only been tested on Linux. Issues on other platforms are as-yet _unknown_ :)
|
The program has only been tested on Linux. Issues on other platforms are as-yet _unknown_ :)
|
||||||
|
@ -359,22 +359,17 @@ class CharInput(Input, inherit_bindings=False):
|
|||||||
"""Limit the value to a single character."""
|
"""Limit the value to a single character."""
|
||||||
return value[-1] if value else " "
|
return value[-1] if value else " "
|
||||||
|
|
||||||
# Using watch_value caused a bug where the character would oscillate between multiple values
|
# Previously this used watch_value,
|
||||||
|
# and had a bug where the character would oscillate between multiple values
|
||||||
# due to a feedback loop between watch_value and on_char_input_char_selected.
|
# due to a feedback loop between watch_value and on_char_input_char_selected.
|
||||||
# watch_value would queue up a CharSelected message, and then on_char_input_char_selected would
|
# watch_value would queue up a CharSelected message, and then on_char_input_char_selected would
|
||||||
# receive an older CharSelected message and set the value to the old value,
|
# receive an older CharSelected message and set the value to the old value,
|
||||||
# which would cause watch_value to queue up another CharSelected event, and it would cycle through values.
|
# which would cause watch_value to queue up another CharSelected event, and it would cycle through values.
|
||||||
# (Usually it wasn't a problem because the key events would be processed in time.)
|
# (Usually it wasn't a problem because the key events would be processed in time.)
|
||||||
# async def watch_value(self, value: str) -> None:
|
def on_input_changed(self, event: Input.Changed) -> None:
|
||||||
# """Called when value changes."""
|
"""Called when value changes."""
|
||||||
# self.post_message(self.CharSelected(value))
|
with self.prevent(Input.Changed):
|
||||||
# Instead, we override on_key to send the message.
|
self.post_message(self.CharSelected(event.value))
|
||||||
async def on_key(self, event: events.Key) -> None:
|
|
||||||
"""Called when a key is pressed."""
|
|
||||||
if event.is_printable:
|
|
||||||
assert event.character is not None, "is_printable should imply character is not None"
|
|
||||||
self.value = event.character
|
|
||||||
self.post_message(self.CharSelected(self.value))
|
|
||||||
|
|
||||||
def validate_cursor_position(self, cursor_position: int) -> int:
|
def validate_cursor_position(self, cursor_position: int) -> int:
|
||||||
"""Force the cursor position to 0 so that it's over the character."""
|
"""Force the cursor position to 0 so that it's over the character."""
|
||||||
|
Loading…
Reference in New Issue
Block a user