egui icon indicating copy to clipboard operation
egui copied to clipboard

Feature Mouse Lock API

Open enomado opened this issue 3 years ago • 7 comments

Trying to investigate on #1602 Seems awesome.

https://user-images.githubusercontent.com/707007/167320729-9f56e8a9-47bc-4a0f-942b-2af1bd6ce01c.mp4

There is a demo you can try your own

enomado avatar May 08 '22 23:05 enomado

Some todos: don't change position on emit release event. For some reason if we lose focus while dragging, we would not get release event and cant unlock cursor

enomado avatar May 09 '22 00:05 enomado

Just realized I can use https://docs.rs/winit/latest/winit/event/enum.DeviceEvent.html#variant.MouseMotion for delta to modify DragValue just by delta and thats all.

enomado avatar May 09 '22 01:05 enomado

converted to draft since you still have some todos

emilk avatar May 11 '22 10:05 emilk

Just want you to check out and write what do you think. Is it worth feature of it costs?

Btw first todo was fixed, and second todo - looks like a bug in winit. browser behave the same way. and looks like we can turn off locking in each component by asking clicked_anywhere.

I think we can add this as experimental feature anyway, but I already happy with my deltas, so I can enjoy DragValue. I just worried about excess complexity. If you are okay with that I'll polish this.

Thank you for reply

enomado avatar May 11 '22 13:05 enomado

This could be merged now I guess

enomado avatar May 12 '22 14:05 enomado

is it really worth the added complexity?

emilk avatar May 21 '22 10:05 emilk

is it really worth the added complexity?

If we dont merge it, anybody who want this must do it from scratch. If we merge this - this add just few odd, experimental methods that could motivate someone to play with this.

I really dont know. perhaps there should be some voting process about it. As for me, the solution is not very kludgy.

enomado avatar May 21 '22 15:05 enomado

Not sure how hard this would be to get across the line, but it is something I'm hoping egui could provide an api for. Very useful for things like draggable values — anyone using Figma will have likely appreciated it when dragging a value and the cursor wraps around the screen, rather than hitting the right edge of the screen and stopping.

bglw avatar Jan 20 '23 09:01 bglw