-
• #2
Just a wild guess:
1) Touching the screen first fires adrag
event, and later atouch
2)dragger
opens the menu
3) the menu sets up bothdrag
andtouch
handlers: https://github.com/espruino/Espruino/blob/master/libs/js/banglejs/Bangle_setUI_Q3.js#L46-L48
4) firing thedrag
event finishes
5) Now thetouch
event is fired and handled by theshowMenu->setUI
code (possibly this doesn't happen if you drag outside the window or drag/touch in just the "right" way)A possible solution might be changing
showMenu();
tosetTimeout(showMenu,0);
, so all handlers get a chance to fire before the menu is set up.
Hi everyone,
I have a problem with the
E.showMenu()
function in the Bangle.js 2. Setup: An app shows its screen. Interaction is done via dragging over the screen or clicking into certain areas. All user input is handled viaBangle.on("drag",…)
. Short drags are interpreted as a "click".This way, when the user clicks into a certain area (a "button" so to say), a menu should open. I use
E.showMenu()
. Problem is: In 99% of all cases, the menu immediately detects a click on the first menu item. This happens before the menu is even shown. As the first menu item is "Continue", the app simply continues and it looks as the menu has never been presented at all.I have shrunken down my app to demonstrate the problem. I hope, the mere 123 lines aren't too long.
If you run this code, at first the menu is shown (explicitly in the main code, line 121). Then, the main part of the app starts. The square on the top right is the "menu button". If you click into it, the menu should open.
...only that it doesn't. In the emulator, you can only see that something is happening through the console log output. On the real hardware, the menu opens shortly and is immediately closed again. The console output shows in both cases that the first menu item, "Continue" is selected.
In the emulator, you can trick the UI: If you perform a drag which ends outside the emulator window, then the next click on the menu button works. And on very rare occasions, the menu on the real hardware also does not close immediately but works flawlessly as expected. But you really need to be lucky to witness this behaviour.
I do not know what is going on here. Do I make something wrong? Is it a bug in the menu system? Some interference with my way of interpreting input? Can anyone help me?
Best regards,
Dirk