Only enable TextArea context menu when able to select by mouse
Reasoning
QtQuick Controls doesn't seem to expect for developers to actually place context menus on top of TextEdit
and TextArea
, so they don't provide options to disable context menus like their QTextEdit counterpart. Unfortunately, this poses a problem when trying to disable text selection by mouse.
In Tokodon, I'm trying to disable text selection when you don't expand a mouse - as to not interfere with actually opening a post and scrolling (on mobile devices) since those require a click or a tap respectively. Except that you can use the context menu to bypass this, which is weird:
You can also "Select All" here too, and there's no way to actually un-select them (to my knowledge) because selectByMouse
is still false.
Solution
Unfortunately for the reasons stated above, there's no disableContextMenu
property and I don't really want to add a custom one that depends on the style, so instead I opted to disable the edit menu entirely when selectByMouse
is false. I think this makes the most sense, and I can't really see where this would break other applications that somehow depend on the context menu showing up, but not being able to select stuff by a mouse - because of the weird ergonomics described above.