Skip to content

Add setting for dragging to select text. - #17

Open
nriley wants to merge 1 commit into
wolfmanstout:mainfrom
nriley:drag_to_select
Open

Add setting for dragging to select text.#17
nriley wants to merge 1 commit into
wolfmanstout:mainfrom
nriley:drag_to_select

Conversation

@nriley

@nriley nriley commented Feb 28, 2023

Copy link
Copy Markdown
Contributor

For use in apps (e.g., some PDF viewers) that do not support clicking to set an insertion point position, nor using the keyboard to select.

For use in apps (e.g., some PDF viewers) that do not support clicking to
set an insertion point position, nor using the keyboard to select.

@wolfmanstout wolfmanstout left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for putting this together!

click_offset_right: int = 0,
hold_shift: bool = False,
start_drag: bool = False,
end_drag: bool = False,

@wolfmanstout wolfmanstout Feb 28, 2023

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unused. I suspect the reason why it is still working is brittle: click() is probably implemented as "click_down(); click_up()", and so the click_down() is a no-op and click() has the effect of click_up(). I don't think we want to rely on that; it's not hard to imagine that calling click() when the button is already down could become an error, or it could call click_up() at the start, etc.

I'd suggest adding an end_drag arg to _move_text_cursor_to_word_locations, having that perform click_up(), and then you can pass this along to that.

return None
finally:
self.keyboard.shift_up()
if drag:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be pulled out into a separate & larger try/finally block, so that any early returns in the function won't leave the mouse in a bad (down) state. Since this risk is introduced very early in the function with the call to move_text_cursor_to_words_generator, the simplest might be to simply rename this function with an "_unsafe" suffix and then reimplement this whole function as simply a try block that wraps the call to the unsafe() function and a finally block that calls click_up().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants