Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Sat Nov 18, 2017 5:21 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Button Arrays
PostPosted: Wed May 03, 2006 6:16 pm 
Offline

Joined: Mon May 01, 2006 3:27 pm
Posts: 60
NewBEE



Can Buttons be arrayed ?



I have 15 buttons and I turn the BGcolor when selected.

I want to have the buttons shaded when clicked and reset previous button. to default backgorund The only way I seen to do this is to set the background and fill color but it takes a copy of this code for all 15 buttons. is there a way to run a function to array the buttons ?



This is a copy of button # 5



func click()





Button_5.bgColor=clr_fillcolor 'Set the background



'Reset all others



Button_1.bgColor=clr_buttonbackground

Button_2.bgColor=clr_buttonbackground

Button_3.bgColor=clr_buttonbackground

Button_4.bgColor=clr_buttonbackground



Button_6.bgColor=clr_buttonbackground

Button_7.bgColor=clr_buttonbackground

Button_8.bgColor=clr_buttonbackground

Button_9.bgColor=clr_buttonbackground

Button_10.bgColor=clr_buttonbackground

Button_11.bgColor=clr_buttonbackground

Button_12.bgColor=clr_buttonbackground

Button_13.bgColor=clr_buttonbackground

Button_14.bgColor=clr_buttonbackground

Button_15.bgColor=clr_buttonbackground

Button_16.bgColor=clr_buttonbackground

Fixture=5

spinner_R.value=RED[Fixture]

spinner_G.value=Green[Fixture]

spinner_B.value=Blue[Fixture]


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 7:14 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Well, first of all, you may wish to experiment with the RadioButtonV2 object which may do exactly what you want without additional code. When one radio button is selected, all other radio buttons on the same screen become deslected. Radio buttons support a push-button-like appearance and can have the selected and deselected colors set independantly.



If you decide to continue with the regular buttons, you can do what you want with minor work. You can create an array and store a reference to each of your buttons in it.



Code:

'Global Code

dim buttonArray[] as objref ButtonV2

init buttonArray := [Button_1, Button_2, Button_3, ... Button_15]



func SelectButtonByIndex(index as integer)

    dim i as integer

    for i = len(buttonArray)-1 to 0 step -1

        buttonArray[i].bgColor = clr_buttonbackground

    next

    buttonArray[index].bgColor = clr_fillcolor

endfunc



'Code for button_1

func click()

    SelectButtonByIndex(0)

endfunc



'Repeat the code for button_1 for all other buttons, incrementing the index by 1 each time.





There are several similar approaches that involve a global function that is called by the click function of each of the individual buttons.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 10:49 am 
Offline

Joined: Mon May 01, 2006 3:27 pm
Posts: 60
Thank you I will try both ways.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 09, 2006 7:43 am 
Hi. You could also simply write a func to change your button properties by passing the button as a reference to the func. I use a similar case with labels.



'Change color labels

func Activate(MyVal as LabelV2)

MyVal.value="ON"

MyVal.bgColor=cl_Green

endfunc



func DeActivate(MyVal as LabelV2)

MyVal.value="OFF"

MyVal.bgColor=cl_Red

endfunc



Now I can pass any label to the func and have it modified. Hope this helps.











**** On another note, why dont I have a radiobutton object?? I even tried to load an old legacy lib that had one, and several objects appeared on the pallete, but the radiobutton did not.


Top
  
 
 Post subject:
PostPosted: Tue May 09, 2006 8:08 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
The radio button object only appears if you have a touch screen on your terminal. If your hardware is configured with a touch screen, the RadioButtonV2 object is in the Basic (pale blue) library.



We have never implemented a keypad driven version of the Radio Button, so if you tell Qlarity Foundry that you don't have a touch screen, it hides the icon as it doesn't make sense on your hardware.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 09, 2006 8:19 am 
Ah ha! In your opinion, how hard would it be for me to modify the existing object to work with keypad instead? I have a great need for it. Thanks


Top
  
 
 Post subject:
PostPosted: Tue May 09, 2006 8:31 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Hard to say. I don't know that it would be too difficult. Again, this is a topic better suited to Ron than me as he did all the keypad adaptations.



The key points would be to add support for the radio button to receive the focus, and to process key messages that have been generated by the key translation object. If you wish to tackle this, I would recommend looking at the code to the ButtonV2 object. Any keypad or focus related code there would be highly relevant. Most of what you need will be encompased by

#if _TOOL_KEYINPUT blocks.



I suspect that this would be an excellent case for inheritance as I don't know that you would need to access any private information in the radio button and by placing the keypad support stuff in a derrived template, it would result in fairly clean code.[/code]

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 7 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group