Objects Question

BlitzMax Forums/BlitzMax Beginners Area/Objects Question

Dezzo(Posted 2009) [#1]
If you press the Key 1 or 2 you can select/highlight the Instance as long as you keep the key pressed. How can i make the selection stay until i press the other key ? ( almost like a switch ). You should be able to highlight 1 Instance only. I totaly miss something important here i know, just canīt figure out what ?




Glenn Dodd(Posted 2009) [#2]
here is a thought starter for you.

you should only turn highlight on if active is true.

Method drawbutton()
klicked()
If active = True Then highlight()
SetColor (color_r,color_g,color_b)
DrawRect (x_pos,y_pos,width,height)
End Method

Method klicked()
If KeyHit(key)
' If KeyDown(key)
' highlight()
Active = True
' Else Active = False
EndIf


you now need a mechanism to turn the other buttons active status to false when you turn one on. the above just turns the active status on and leaves it on.

hope this points you in the right direction


Dezzo(Posted 2009) [#3]
Thx for the fast Reply !
I found a Solution but i donīt think that itīs an elegant one ...
What do you think ?




jsp(Posted 2009) [#4]
Have a look for some comments in the code




Jesse(Posted 2009) [#5]
I would do it something like this.


but I was devating whether or not to pass the variable in the draw method.
doing it this way saves several if statements but in my opinion makes it less flexible.