- Home /
Unity UI: How to stop select event from propagating?
I am trying to achieve a menu list with scroll up / down buttons.
The issue I am having is that when the scroll buttons are clicked, the focus is taken
from the selected menu item and given to the scroll button that was clicked,
while I want the menu item that was selected to retain focus.
I can save the previously selected menu item and re-select it, but this causes the select event
and thus the select animation to fire again, which is not ideal.
So I was wondering if it is possible to stop the select event from firing on the selected
item, but not propagate to the event system?
I am also wondering how to do this since I am trying to create a "Load Game" menu with a series of selectable objects in a scrollable list. If anyone can figure out how to prevent the deselection of UI objects before a button's onclick event is triggered please post here.
Answer by The_Immovable · Oct 07, 2015 at 07:02 PM
We have encountered 2 solutions:
1.-You have to OVERRIDE the OnPointerDown event on the InputField, and changing its behavior to OnClick event, so you have to make OnClick equal to OnPointerDown and erase OnPointerDown behavior.
2.-You can trigger the InputField keyboard implicitly so you can position a transparent UI Button over the InputField and make this button call the InputField OnPointerDown handler with ExecuteEvents class
BTW number one is easier, you just need to create a Script that inherit InputField and change the events.
Your answer
Follow this Question
Related Questions
How do I stop EventSystem.currentSelectedGameObject from changing on a button press 0 Answers
Broadcast mouse event on Canvas 0 Answers
How to add callback for button press to a private function (New UI)? 1 Answer
EventSystem not recognizing child objects 0 Answers
Hide/show UI Button and trigger the OnPointerDown event ?! 0 Answers