Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Light Switch Widget / Quick Launcher] Swipe to change brightness triggers quicklaunch as well #2754

Closed
thyttan opened this issue May 14, 2023 · 2 comments
Labels
type-bug Something isn't working

Comments

@thyttan
Copy link
Collaborator

thyttan commented May 14, 2023

I closed the issue for now since I mixed up swipe and drag events when thinking about this.

Affected hardware version

Bangle 2

Your firmware version

2v17.106

The bug

Tapping the Light Switch Widget and then draging changes the brightness like it should, but the swipe handler of quick launcher is also triggered which ideally wouldn't happen.

To fix this I've tried to make use of the new function E.stopEventPropagation() introduced in espruino/Espruino@35c8cb9 but I can't manage to make Light Switch Widget stop Quick Launcher from acting also, or vice versa.

I added E.stopEventPropagation(); inside the dragListener function
in Light Switch Widget here and inside the swipe handler in Quick Launcher here. But neither try stopped the other app from executing.

From the documentation:

When using events with X.on('foo', function() { ... })
and then X.emit('foo') you might want to stop subsequent
event handlers from being executed.
Calling this function doing the execution of events will
ensure that no subsequent event handlers are executed.

var X = {}; // in Espruino all objects are EventEmitters
X.on('foo', function() { print("A"); })
X.on('foo', function() { print("B"); E.stopEventPropagation(); })
X.on('foo', function() { print("C"); })
X.emit('foo');
// prints A,B but not C

First mentioned in #2743:

Actually no need - I've just implemented option 3 in 35c8cb9be11ce76ea1829a4a8b40f2ab051bb60b in the Espruino repo.

So you just need:

E.stopEventPropagation&&E.stopEventPropagation();

And that should do it I hope, while being backwards compatible.

Originally posted by @gfwilliams in #2743 (comment)

Installed apps

notify (0.12)
podadrem (0.07)
spotrem (0.07)
android (0.23)
lightswitch (0.06)
widanclk (0.02)
backswipe (0.02)
torch (0.11)
calculator (0.07)
agenda (0.13)
smpltmr (0.07)
kbmulti (0.05)
widram (0.03)
widbthide (0.01)
messageicons (0.05)
boot (0.57)
runplus (0.18)
dtlaunch (0.23)
alarm (0.41)
hrmmar (0.02)
taglaunch (0.03)
swscroll (0.03)
messagegui (0.65)
longpressbuzz (0.01)
bwclklite (0.33)
bwclk (0.32)
widmessages (0.05)
clkinfostopw (0.03)
recorder (0.23)
health (0.23)
quicklaunch (0.15)
polymath (0.01)
sched (0.22)
fastreset (0.01)
setting (0.60)
clock_info (0.03)
messages (0.59)
drained (0.03)
widminbat (0.03)
powermanager (0.10)
pebblepp (0.01)
fastload (0.04)

@thyttan thyttan added the type-bug Something isn't working label May 14, 2023
@thyttan thyttan closed this as completed May 14, 2023
@thyttan
Copy link
Collaborator Author

thyttan commented May 14, 2023

I closed the issue for now since I mixed up swipe and drag events when thinking about this.

However the bug with both handlers executing I have not solved.

@gfwilliams
Copy link
Member

I guess you need to do something a bit like:

dragUsed = false;
Bangle.on('drag', {
  if (light switch widget is doing something) {  
     dragUsed = true;
    setTimeout(function() { dragUsed=false; }, 500);
  }   
});
Bangle.on('swipe', {
  if (dragUsed) 
    E.stopEventPropagation&&E.stopEventPropagation();
  dragUsed = false;
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants