swift-win32 icon indicating copy to clipboard operation
swift-win32 copied to clipboard

WIP: Label inherits View and clean event handling code

Open yostane opened this issue 3 years ago • 7 comments

Fixes: #442

yostane avatar Apr 08 '21 13:04 yostane

Thanks for the patch @yostane! Does this not break the current mechanism for handling events? I think that the long term solution here is to use gesture recognizers and attach one to the button, but for the mean time, it would be nice to have something that continues to function.

compnerd avatar Apr 08 '21 15:04 compnerd

Hi you're welcome :).

Ah ok I understand. What should be done is:

  • Make Label inherit from View
  • Keep the current event handling mechanism (because GestureRecognizer is not implemented yet)

If that's what is expected, I will update my patch if possible.

yostane avatar Apr 08 '21 15:04 yostane

Yeah, I think that would be the best middle ground where we dont have the desired state, but keep the ability to detect the click. I think that follow ups for adding GestureRecognizers would be wonderful :)

compnerd avatar Apr 08 '21 16:04 compnerd

Hi @compnerd . Can you take a look at my last modifications please ?

I transferred some event handling code from Control into Label to allow the developer to use the addTarget method on the Label. I have added a click handler on the the Label of the HelloWorld example and it responds to the click. Is this how it should be done ? It that's ok as a temporary solution, I will remove some test code as well as the the WIP status

Thanks,

yostane avatar Apr 14 '21 13:04 yostane

I tried moving code in Label+Temporary but this seems more complex than expected because of visibility problems. The current Laabel+Temporary file contains code that did not require changes.

Instead of spending more time on this temporary solution, maybe it would be better to postpone this MR and focus more on gesture recognizer. What do you think ?

yostane avatar Apr 27 '21 10:04 yostane

Postponing and focusing on gesture recognizer sounds like a good plan to me. @egorzhdan had previously looked at the gesture recognizer bits for menus, not sure if he has any thoughts about what exactly would be the minimum work needed to get it working.

compnerd avatar Apr 27 '21 14:04 compnerd

Yeah, I've looked into handling menu item clicks before, but I don't have a working implementation of it. IIUC for menus that would require handling WM_COMMAND events & deducing the menu item that was clicked based on LOWORD(wParam), but for labels the event could be different.

egorzhdan avatar May 02 '21 19:05 egorzhdan