How to limit Inbound/Release events to the control that was initially pressed
User Question:
Is there a way to limit inbound/release events to the control that was initially pressed? For example, if you press button_1 and move your finger off of it, the button should go to an up-state, and if you move back to it and release, button_1's action should still be triggered. If you move to button_2 from button_1, however, button_2's action should not be triggered.
Answer:
Currently, the best way to achieve this functionality is by setting a boolean for is_pressed on a press event and checking that boolean on any other events for buttons that you don't want to trigger. Keep in mind that you will have to reset the boolean on a release event, which may not be triggered from the control that registered the press event. For this reason, it may be best to have a universal release event on the layer or screen and reset the booleans for all affected buttons.
Further Note:
This situation has been asked about a few times, but may not always be the desired user flow. For instance, if you have a keyboard, the user may press the wrong key and want to adjust their choice while their finger is still on the screen.
That said, if there is enough demand for an easier way to accomplish the functionality described in the user question, it may be worth considering adding some sort of boolean option directly to the controls or events in Storyboard. If this is functionality you see yourself requiring often, please leave a comment to voice your interest to increase the likelihood that it will be added to a future version of Storyboard.
Comments
I'm interested in an easier way to handle this type behavior. We have a design that has a screen divider that the user wants to move into 3 possible positions based on a swipe over the divider. The problem I'm seeing is that I have keys set to trigger on release above and below the divider and currently the swipe release is triggering those keys when I don't want it to. For now, I can try the boolean approach to only process the key release if it was the object originally pressed.
Another option to consider is the grd_opaque control or layer variable which indicates if events should reach those controls below it.
It might have helped if I'd spent a little more time with the manual. As I was trying to figure out how to implement the above, I realized I had missed the gre.touch event which does exactly what I need already.
@Jonathan I'm happy to hear you were able to get it working!
Having read your initial message again, I can see that I misunderstood the problem you were facing. The grd_opaque variable (Also known as "Stop Events" in the UI), is useful, but for a different scenario. In fact it's enabled by default on Controls.
Cheers!
I definitely would like to have this feature. An easy 'pressed-release' that only sends the event if control was originally pressed. or something
Hi all!,
Can anyone explain to me the grd_opaque variable? As far as I've tried, it doesn't have any effect to my events.
What I try to do is:
I have a control (button) with a release and inbound action. Release action triggers to a screen transition and inbound should desactive that release action. Firstly, I used data change with active = 0 tag in the inbound action, making active = 1 when release of the own screen. It worked fine BUT for some buttons I needed change the active tag in the lua script depending on the situation, so sometimes the release of the screen shoudn't make active = 1.
That's why I thought grd_opaque could work, but it didn't.
I found the following in the documentation:
grd_opaque 1u1 Indicates if the control is opaque to events. If opaque (1), the control will block events from being handled by other controls. If the value is 0, the events flow through the control to ones behind it.
THANKS!
Please sign in to leave a comment.