You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
related to #176
I'm experimenting with ways to intercept/ process mouse click in a RTK. I also have a longstanding problem dragging files/objects directly on the the RTE. drag Handlers refuse to work there, though they're good elsewhere in the window. The workaround for both problems turned out to be an Overlay.
It's obvious (in retrospect!) that an overlay will receive a dragged file, the bigger challenge is mouse clicks - how to intercept some special cases without disabling normal text-editing mouse function. I decided to divert option-clicks to the overlay, and pass the rest to the RTE.
The trick has 2 parts: use .allowsHitTesting() to enable/disable mouse clicks being diverted to the overlay, and detect option key with Notification Manager. My usual code for checking option key would check flags in CGEventSource - but those are modifiers for the last event. And are set too late. Instead I have the Notification Manager inform me for each modifier key up/down.
this gives a 'higher resolution' response to modifier key states. there seems to be no lag introduced.
the one last shenanigan is swiftui won't give Invisible things mouse clicks. So I made the overlay blue, at 1% opacity, and that seemed to be enough.
the end goal is clickable text tokens with custom behaviors. That will require knowing what text was clicked - a challenge for the future.
{HStack{Color.blue.opacity(windowInfo.highlightDrag ? 0.4 : 0.01).allowsHitTesting(modKeyState.isOptionKeyDown) // 😎
.onTapGesture{ // this is really an option click
print("option click")
// † and however might i calculate what was clicked on...?
// for now, bring up a general purpose wildcard editor
}.dropDestination(for:URL.self, action: handleDrop,isTargeted: highlightDrop) // DropDestination
}}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
related to #176
I'm experimenting with ways to intercept/ process mouse click in a RTK. I also have a longstanding problem dragging files/objects directly on the the RTE. drag Handlers refuse to work there, though they're good elsewhere in the window. The workaround for both problems turned out to be an Overlay.
It's obvious (in retrospect!) that an overlay will receive a dragged file, the bigger challenge is mouse clicks - how to intercept some special cases without disabling normal text-editing mouse function. I decided to divert option-clicks to the overlay, and pass the rest to the RTE.
The trick has 2 parts: use
.allowsHitTesting()
to enable/disable mouse clicks being diverted to the overlay, and detect option key with Notification Manager. My usual code for checking option key would check flags in CGEventSource - but those are modifiers for the last event. And are set too late. Instead I have the Notification Manager inform me for each modifier key up/down.this gives a 'higher resolution' response to modifier key states. there seems to be no lag introduced.
the one last shenanigan is swiftui won't give Invisible things mouse clicks. So I made the overlay blue, at 1% opacity, and that seemed to be enough.
the end goal is clickable text tokens with custom behaviors. That will require knowing what text was clicked - a challenge for the future.
Beta Was this translation helpful? Give feedback.
All reactions