You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Dani

Intermediate

  • "Dani" started this thread

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

1

Tuesday, December 4th 2012, 4:37pm

ToggleButton - how change its state

Hey there,

the ToggleButton is a two-state button that stays down when you push it and is supposed to come up when you push it again!
Or am I mistaken here?

When using a couple of ToggleButtons they do behave like that.
But a single ToggleButton stays pushed; it does not come back up by pushing it again.

I tried using JToggleButton and it is the same beahaviour so I am confused.
Is there any way to use a single ToggleButton like a switch?

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
'add a ToggleButton and a CommandButton

'when it is down
Public Sub Command1_Click()
     ToggleButton1.Parent.setSelected(False)            'does not push the button
'     ToggleButton1.Parent.doClick()                    'does not push the button
'     ToggleButton1.Parent.getModel.setPressed(False)   'does not push the button
'     ToggleButton1.Parent.getModel.setSelected(False)  'does not push the button
End Sub

'when it is up
'Public Sub Command1_Click()
'     ToggleButton1.Parent.setSelected(True)            'pushes the button
'     ToggleButton1.Parent.doClick()                    'pushes the button
'     ToggleButton1.Parent.getModel.setPressed(True)    'does not push the button
'     ToggleButton1.Parent.getModel.setSelected(True)   'pushes the button
'End Sub


Dani

Edit: I'd like to use the ToggleButton like a CheckBox. So I was trying to work with a hidden second ToggleButton but it seems like there is no way to get the first ToggleButton to appear 'unpushed' unless you actually click on second one!?

This post has been edited 2 times, last edit by "Dani" (Dec 4th 2012, 4:48pm)


Dani

Intermediate

  • "Dani" started this thread

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

2

Wednesday, December 5th 2012, 9:00am

Hey there,

well, this is the two button approach

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
'requires 2 ToggleButtons, second Button set visible = False

Public Sub ToggleButton1_Click()
   Static blnLast As Boolean = False
   If blnLast = True Then 
      ToggleButton2.Parent.doClick()
      Debug.Print "stopping thread..."
   Else
      Debug.Print "starting thread..."
   End If
   blnLast = ToggleButton1.Value
End Sub


does anyone come up with a single button approach?


Dani

Rate this thread
WoltLab Burning Board