Forum Discussion
Trigger event on focus
Hello,
I'm quite familiar with triggering events when a control loses focus or when a user clicks an object, but I'm curious to know if anyone's found a way to trigger an event when a control gains focus - either via a mouse click or key press (tab).
Thanks!
23 Replies
- WendyFarmerSuper Hero
Hi Greg
if I understand you - when the user clicks inside a entry field you want to be able to trigger another action?
Here is a rough sample if that helps
If that's not what you meant can you share a slide and someone can take a look for you
- GregHagarCommunity Member
Hi Wendy,
Thanks for the response - that is about half of what I'm asking, but not quite the whole of it. :)
I understand how to trigger actions when an object is clicked on, but what I'm looking to do is trigger an action when the user presses the tab key to move to the next object on the slide.
Imagine an input form where the user moves from field to field by pressing the tab key. To simulate this in SL, I would create a "text entry" object to represent each of the form fields and set the tab order of those text entry fields to match the flow of the form.
As the user moves through the form, I would provide feedback on their input (by checking it against the variable associated with each text entry field. Typically, I do this using a "when control loses focus" trigger on the field being validated, and that's all good.
In this case I need to do something subtly different - I don't want to validate the user input as soon as the current field loses focus, I want to validate it when the next field on the form gains focus. If the user is only using the mouse to move to the next field, this isn't a problem, because as you've demonstrated, I can just use the "when user clicks" trigger. Where I get stuck with this is if the user tabs to the next field - there is no equivalent of the "when user clicks" trigger for an object that gains focus via tab order.
I've added a very simplified example of what I'm describing to the file you shared. I've attached it to this post.
Thanks again for your help and attention!
- PhilMayorSuper Hero
I read this yesterday and thought the same as Wendy that half of it would be the on click trigger. Because of accessibility options it would be nice to have a trigger for when control has focus.
- PhilMayorSuper Hero
Sorry forgot to say, I dont think there is any way to do this now.
- GregHagarCommunity Member
Hi Phil, great point about accessibility - what I'm describing would be quite helpful from that perspective!
I assumed what I was hoping to do wasn't really possible yet, but I thought I'd see what community had to say just in case - they've certainly provided some fantastic insight in the past (and will in the future I'm sure)!
- FionaMacelliCommunity Member
Is there a way to do what Greg is describing here yet? Activate a trigger when an object has been put into focus (but not clicked on) via the keyboard?
Hi Fiona,
You can activate a trigger by selecting the object once it's in focus, which would require hitting Enter on the keyboard.
I look forward to hearing if anyone in the community has created a similar design and would be able to pop in and help you here.
- FionaMacelliCommunity Member
I believe that what Greg was looking for was something to activate the trigger without selecting the object (using the keyboard or otherwise), just having it be "in focus" via the tab key. That is what I'm looking for anyway.
I wouldn't exactly call it a critical feature, since for accessibility reasons you would not normally want to have something new appear onscreen without the user having done something explicitly to cause the change. But it would be helpful in my current project to have something like this in order to make a particular activity accessible. And from what I understand of Greg's thread, it would be useful for simulating a form-entry.
I have been able to get satisfactory results using the 'key press' trigger and setting the key to be pressed as the 'tab' key. It doesn't trigger quite when I want it to, and it doesn't work in reverse order (when tabbing backwards through the tab order). Assigning both tab and shift to activate the trigger on key-press doesn't seem to be accepted even though the trigger panel does let me enter the key combination.
All this is to say: thanks for the suggestion Leslie, but it doesn't meet my current need; it's an uncommon use case and there's lots of other feature requests that would take priority; and if anyone else is trying to do something similar, the key-press trigger has worked the best.
- BenjaminWeilCommunity Member
Hi all, any improvement about this important issue in 2021 ? Building accessible e-learning requires that focus is taken into account the same way hover is.
Hello Benjamin,
This conversation is a bit dated and we've not released any additional features specific to objects being in focus.
As far as accessibility, we have made improvements to ensure Slide Content Is More Accessible.
Would you be able to further explain what you are working to create and how that relates to accessibility?
Related Content
- 7 months ago
- 2 years ago
- 5 months ago
- 10 years ago