cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Passing which button was clicked to a service

HD_10225728
6-Contributor

Passing which button was clicked to a service

Hello,

 

i want to build a simple calculator. For this I would want to create 10 buttons for each digit and 6 buttons for plus, minus, multiply, divide, delete, equal. 

Then a computation services that takes the label of the buttons pressed as input.

 

But here I am already stuck. I haven't found a way to pass a value for a button to a service. Logic; if button "4" was clicked, input parameter "digit" should be "4".

 

I have already tried setting a contextID and working with event routers but the problem is that the context ID should only be passed  when the button is clicked, but it will always pass.  

 

I would appreciate any help!

 

Thank you.

ACCEPTED SOLUTION

Accepted Solutions

If you use an expression before the Event Router I believe this should work (to control when exactly the value is passed to the Event Router).

Can you please check if the example I built in attachment works? (it's not very optimized...)

View solution in original post

3 REPLIES 3

If you use an expression before the Event Router I believe this should work (to control when exactly the value is passed to the Event Router).

Can you please check if the example I built in attachment works? (it's not very optimized...)

Thank you so much!

So the only way would be to create more than 16 Expressions (one for each button)?

 

Hi again, 

I think the expression router and event combo, even if it is a bit of work to write an expression for each button, could work. Thank you!

 

However can you think of a way to implement the logic, that unless a user clicks on one of the operator buttons, the numbers pressed should be appended?

So if i first click 1, then 2, it should be number 12. 

 

I am also a bit clueless where to store the numbers and the operators that should be passed to the calculation service. In an non-persistent InfoTable thing property? 

 

Thank you!

 

Announcements


Top Tags