Button_Event Programming Tips
ajish.raju
Posts: 185
There are multiple ways to use a button_event, i am wondering which is the best way based on standards and code reusability. Here are the options that i feel are there, please mention if there are any other options.
1.
2.
3.
What is the general consensus on button_events and how to write them well.
1.
BUTTON_EVENT [dvTP,0] { PUSH: { SWITCH(Button.input.channel) { CASE 2833://do something CASE 2838:// CASE 2839:// } } }This is good since even if the touch panel array is more, channel number will never hit 4000 so it will always fire. But you always have to refer to the touch panel on where the channel number is used
2.
BUTTON_EVENT [dvTP,btPage] { PUSH: { SWITCH(get_last(btPage)) { CASE 1://do something CASE 2:// CASE 3:// } } }Here you declare an integer variable which will have the channel numbers. The variable can be commented so that you can know what each channel number is for so you don't have to refer to the touch panel. You need to be careful if your touch panel array x integer variable < 4000 or it wont fire.
3.
DEFINE_CONSTANT INTEGER BTN_ALLOW_TOBE_MONITORED = 1555 INTEGER BTN_ALLOW_TO_MONITOR = 1556 INTEGER BTN_MOD_GLOBAL_PB = 1557 DEFINE_EVENT BUTTON_EVENT [dvTP,BTN_MOD_GLOBAL_PB] { PUSH: { } } BUTTON_EVENT [dvTP,BTN_ALLOW_TO_MONITOR] { PUSH: { } } BUTTON_EVENT [dvTP,BTN_ALLOW_TOBE_MONITORED] { PUSH: { } }Here you will have multiple constant declarations so its a bit tedious to write all these declarations.
What is the general consensus on button_events and how to write them well.
Failed to load the poll.
Failed to load the poll.
0