/
Toggle Button Control

Toggle Button Control

ORG-11096

Sample OPX to download to try: Toggle Button.opx



Origin 2015 support add an text box named "labtalk Variable to toggle" in the Button Settings dialog.The variable can be pass to script file.

Labtalk Variable
Description
 
state:1 or statebutton will be toggled between states that is pressed-down or not pressed-down
state:2,state:3,etcbutton has 2/3 states, icon image will use itself by default and another one/two following in the bitmap

Note:button will be disable if LabTalk variable is not defined or contains missing value

 

How to

  1. Open the Customize Toolbar dialog box (View:Toolbars) and select the Button Groups tab.
  2. Select the User Defined button group from the Groups list.
  3. Select a button in the Buttons group.
  4. Click on the Settings button in the Button group. This opens the Button Settings dialog box.

         

Examples:

Download Toggle Button.opx and play.

    1.press down/up states


1.a. Create a ogs file and save with follow script as toggle button.ogs.

///Defind labtalk variable as myVar
if(myVar)
    type -b "button is pressing up"; 
 else
    type -b "button is pressing down";

1.b Open button settings dialog,Click browse button,browse and select toggle button.ogs as File Name.

1.c Fill myVar:1 in Labtalk Variable to toggle text box.close dialog,drag button to origin workspace.

1.d Run "int myVar;" in script window, button is enable now, click it, button is press down.

    2. Multiple states

2.a Create a ogs file and save with follow script as toggle button_1.ogs.

[Main]
switch (state)
{
    case 0:
        run.section(,State0);
        break;
    case 1:
        run.section(,State1); 
        break;
    case 2:
        run.section(,State2); 
        break;
}
[State0]
ty -b "toggle button to 2nd state".
[State1]
ty -b "toggle button to 3rd state".
[State2]
ty -b "toggle button to 1st state".

2.b Open button settings dialog,Click browse button,browse and select toggle button_1.ogs as File Name.

2.c Fill state:3 in Labtalk Variable to toggle text box.set section name as Main,close dialog,drag button to origin workspace.

2.d Run "state=0;" in script window, button is enable now, click it, button icon become the next button icon in the bitmap.

Related content

Collapsible Menu and Context Menus
Collapsible Menu and Context Menus
More like this
Provide GUI for customization of LR report table on graph
Provide GUI for customization of LR report table on graph
More like this
Multiple Special Ticks and Other Tick Label Improvements
Multiple Special Ticks and Other Tick Label Improvements
More like this
Hotkey O, N and L for New Output Actions
Hotkey O, N and L for New Output Actions
More like this
Origin 2015 SR2 Features
Origin 2015 SR2 Features
More like this
A4 - Axis dialog Improvements in Origin 2015
A4 - Axis dialog Improvements in Origin 2015
More like this