mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Calculating offset correctly
This commit is contained in:
@@ -42,7 +42,7 @@ Screen {
|
||||
}
|
||||
|
||||
#topsearchbox {
|
||||
width: 10;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#footer {
|
||||
|
||||
@@ -178,13 +178,14 @@ class TextInput(TextWidgetBase, can_focus=True):
|
||||
|
||||
def on_click(self, event: events.Click) -> None:
|
||||
# TODO: Support more than ASCII
|
||||
if not self.content_region.contains_point((event.x, event.y)):
|
||||
if not self.content_region.contains_point((event.screen_x, event.screen_y)):
|
||||
return
|
||||
|
||||
self._cursor_blink_visible = True
|
||||
start_index, end_index = self.visible_range
|
||||
|
||||
new_cursor_index = start_index + event.x - self.content_region.x
|
||||
new_cursor_index = start_index + event.screen_x - self.content_region.x
|
||||
print(new_cursor_index)
|
||||
new_cursor_index = clamp(new_cursor_index, 0, len(self._editor.content))
|
||||
self._editor.cursor_index = new_cursor_index
|
||||
print(self._editor.cursor_index)
|
||||
|
||||
Reference in New Issue
Block a user