Home » Eclipse Projects » GEF » [GEF4] About events consumption and policy ordering
| [GEF4] About events consumption and policy ordering [message #1705943] |
Thu, 20 August 2015 10:15  |
Camille Letavernier Messages: 951 Registered: February 2011 |
Senior Member |
|
|
Hi,
I'm trying to implement several different actions on the same mouse action (Left click). The general idea is that, when I'm manipulating the Palette, the SelectionOnClick policy should not handle the click events.
So I have a PaletteModel that stores an active PaletteTool. If there is an active PaletteTool, then SelectionOnClick does nothing.
However, depending on the order in which the ClickPolicies are invoked, I can get one of the following sequences:
On click:
- PaletteOnClick: create something, consume the event, clear the palette model
- SelectionOnClick: PaletteModel is empty, select
On click:
- SelectionOnClick: PaletteModel is not empty, do nothing
- PaletteOnClick: create something, consume the event, clear the palette model
The second sequence is OK, but the first one is not.
First question: Is there a way to specify the order of the policies, or should we have a single ClickPolicy, which then delegates to a different mechanism for handling the ordering? (e.g. a single ClickPolicy, that will delegate to either SelectionTool or PaletteCreationTool, rather than a SelectionPolicy and a PaletteToolPolicy)
Second question: It seems that "consuming" an event is not really an option. GEF4 iterates on all policies even if the (JavaFX) event has been consumed. Additionally, if I check for e.isConsumed() in the SelectionOnClick policy, I get other side effects, because for example the Drag policy always consumes the "press" event (So the SelectionOnClick policy is always disabled in this case). Are there some recommandations to either properly use events consumption, or to avoid using this mechanism outside tools?
Thanks,
Camille
Camille Letavernier
[Updated on: Thu, 20 August 2015 10:15] Report message to a moderator
|
|
|
| Re: [GEF4] About events consumption and policy ordering [message #1705949 is a reply to message #1705943] |
Thu, 20 August 2015 11:26   |
|
Camille Letavernier wrote on Thu, 20 August 2015 12:15
First question: Is there a way to specify the order of the policies, or should we have a single ClickPolicy, which then delegates to a different mechanism for handling the ordering? (e.g. a single ClickPolicy, that will delegate to either SelectionTool or PaletteCreationTool, rather than a SelectionPolicy and a PaletteToolPolicy)
The order in which policies are processed is not defined, so yes, this would be a valid scenario.
Camille Letavernier wrote on Thu, 20 August 2015 12:15
Second question: It seems that "consuming" an event is not really an option. GEF4 iterates on all policies even if the (JavaFX) event has been consumed. Additionally, if I check for e.isConsumed() in the SelectionOnClick policy, I get other side effects, because for example the Drag policy always consumes the "press" event (So the SelectionOnClick policy is always disabled in this case). Are there some recommandations to either properly use events consumption, or to avoid using this mechanism outside tools?
First, the fact that the press event is consumed within FXClickDragTool seems to be inconsistent to me (I think its there historically, because we first had distinct tools for click and drag). IMHO the tools should not consume any events themselves. Please open a bug to report this. Second, tools currently do not evaluate whether the event was consumed by a policy. IMHO it could make sense to evaluate that when iterating over the policies as you propose. Could you please open another bug to request this as an enhancement?
|
|
| |
Goto Forum:
Current Time: Tue Oct 03 12:33:32 GMT 2023
Powered by FUDForum. Page generated in 0.01813 seconds
|