PDA

View Full Version : Passing index to functions with Inputs and Buttons



Unreal_Ed
05-17-2018, 01:21 AM
It would be great to be have Inputs and Buttons pass their input/buttons index to the function they call.

Currently, you may want to have several buttons/inputs do nearly the same thing, but the quickest way to do that is to have each of them call their own function that will call FunctionB which takes an index (or a string or something) as a parameter. If you have a lot of buttons, that means a lot of code that we could easily live without if the button/inputs would pass their index on top of obj, player, alt, input_value, and selected. We could then all have them call their FunctionB and do different things inside the function itself.

This might seem like it's a small thing, but sometimes you can potentially have a LOT of buttons/inputs that do similar things but with 1 difference such as which numbered input did you type a word in.

dzikakulka
05-17-2018, 05:48 AM
Yeah.

http://www.berserk-games.com/forums/showthread.php?3744-Passing-parameters-to-button-s-click_function

http://www.berserk-games.com/forums/showthread.php?3975-Make-button-click-functions-return-button-parameters-and-or-index

http://www.berserk-games.com/forums/showthread.php?4347-A-way-to-have-getButtons(buttonname)-return-the-index

http://www.berserk-games.com/forums/showthread.php?4478-Button-Input-Event-Callback-Index

http://www.berserk-games.com/forums/showthread.php?2643-Add-parameters-parameters-to-button-parameters&highlight=button

Knil
05-25-2018, 03:23 PM
These old createButton() based are consider depreciated at this point now that you can spawn 3d UI with the new Xml UI system.