PDA

View Full Version : Event Priorities?



bholyoak@abovetraining.co
25 Apr 2012, 6:17 PM
Ext version tested:

Ext 4.0.7
Browser versions tested against:

18.0.1025.162
Description:

I'm just now really starting to delve into ExtJS so forgive me if this seems obvious to everyone else.

Specifically, I'm creating a toolbar with a menu button. In the button's menu I set the "beforeshow" and "beforehide" listeners to output a message to the console showing when they were fired, and also their parent button's pressed state. Then I set the button's toggle listener to output it's pressed state to the console.
Steps to reproduce the problem:

When I then click the button to open the menu, I see these messages:

button toggle called:pressed=true
menu beforeshow called:pressed=true

All's how I'd expect here. But when I click the button again (to close the menu) I see:

menu beforehide called:pressed=true
button toggle called:pressed=false
The result that was expected:

To me it seems that the pressed state should be set before the menu is hidden (and "beforehide" is called), since the menu being hidden is a RESULT of the button actually being clicked first...
The result that occurs instead:

The button's "pressed" state is being set AFTER "beforehide" is called.
Possible fix:

Have the button's "pressed" state set before cascading events are fired off?
Additional CSS used:

only default ext-all.css
Operating System:


Windows 7

scottmartin
26 Apr 2012, 10:16 AM
Have you tried using 4.1 to see if this is still an issue?

Regards,
Scott.

bholyoak@abovetraining.co
27 Apr 2012, 8:23 AM
I just tried this in 4.1 and it works the same.

bholyoak@abovetraining.co
30 Apr 2012, 8:29 AM
Any answers for this? I tried to submit this as a bug, noticed that my formatting wasn't correct for my submission, so I changed it... but it got moved to this section.

I want to know if this is a bug or not, because it seems to me like it is. And if it's "working as intended", I'd just like to know the reason it was intended to work this way?

scottmartin
30 Apr 2012, 8:35 AM
Can I get you to create a small working example of exactly what you are doing so we can have a look?

Regards,
Scott.

bholyoak@abovetraining.co
30 Apr 2012, 9:55 AM
I could post code, but it'd take time I don't have right now. I think the question I asked is very simple and doesn't require code to prove until it has been established that it should NOT work this way.

If it is NOT meant to work this way, I'll illustrate with code. If the answer is "YES", I'd like to know why. Surely a developer would know if this is by design or not.

Here's a quick summary again: I click a button (with toggle enabled), and the button menu's event "beforeshow" knows the button's current pressed state is "true" (pressed is set before "beforeshow" is fired). However, when I click the button again, the button's state is not set to "false" before the "beforehide" event is fired. Therefore, "beforehide" never really can know the true state of the parent button (unless it's safe to assume that it's state is always opposite of what is reported).

Assuming for a minute that things work as I described, would this be a bug or would it be "working as intended" please?