Core Function GUICreateComboBox
From Sputnik Wiki
(Difference between revisions)
(→Example) |
(→Example) |
||
Line 35: | Line 35: | ||
=== Example === | === Example === | ||
− | |||
− | |||
<syntaxhighlight lang="sputnik"> | <syntaxhighlight lang="sputnik"> | ||
// Create the GUI | // Create the GUI | ||
− | $GUI = GUICreate("Window", "Hello", | + | Glob $GUI = GUICreate("Window", "Hello", 550, 350); |
// Show the GUI | // Show the GUI | ||
GUILoad( $GUI ); | GUILoad( $GUI ); | ||
// Create a ComboBox | // Create a ComboBox | ||
− | $ | + | Glob $ComboBox = GUICreate("ComboBox", $GUI, 8, 8, 300, 300); |
− | + | // Do some stuff | |
− | + | GUIComboBox( $ComboBox, "SetItems", array(100, 200, 300, 400) ); | |
+ | GUIComboBox( $ComboBox, "AddItem", 450 ); | ||
+ | GUIComboBox( $ComboBox, "AddItems", array(500, 600, 700, "Hello") ); | ||
+ | GUIComboBox( $ComboBox, "InsertItem", "lol", 3 ); | ||
+ | GUIComboBox( $ComboBox, "InsertItems", array("One", "Two", "Three", "Four"), 4 ); | ||
+ | GUIComboBox( $ComboBox, "DelItem", "Three" ); | ||
+ | GUIComboBox( $ComboBox, "DelItemAt", 0 ); | ||
+ | $Items = GUIComboBox( $ComboBox, "GetItems" ); | ||
+ | foreach($Items as $i) | ||
+ | { | ||
+ | println("Item '$i'"); | ||
+ | } | ||
+ | // Add Links | ||
+ | GUILink($ComboBox, "SelectedIndexChanged", "onChange();"); | ||
+ | |||
+ | |||
// Keep the GUI running as long as long as the window is open | // Keep the GUI running as long as long as the window is open | ||
While ( GUIStatus( $GUI ) ) DoEvents( ); | While ( GUIStatus( $GUI ) ) DoEvents( ); | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | Function | + | Function onChange() |
{ | { | ||
− | + | my $Index = $arg[0]; | |
− | + | my $Text = $arg[1]; | |
− | + | println("ComboBox was clicked... Index '$Index' | Text '$Text'"); | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Core Function]] | [[Category:Core Function]] |
Revision as of 01:29, 25 April 2012
GUICreate( "ComboBox", <gui object>, <Left>, <Top>, <Width>, <Height> )
Contents |
Description
Create a ComboBox
Parameters
gui object
The GUI object to place the ComboBox on.
text
The text the button should display.
left
LEFT Position to create the object.
top
TOP Position to create the object.
width
Optional; The width of the object.
height
Optional; The height of the object.
Return Value
Success: Returns the new GUI object.
Failure: Returns 0 if error occurs.
Example
// Create the GUI Glob $GUI = GUICreate("Window", "Hello", 550, 350); // Show the GUI GUILoad( $GUI ); // Create a ComboBox Glob $ComboBox = GUICreate("ComboBox", $GUI, 8, 8, 300, 300); // Do some stuff GUIComboBox( $ComboBox, "SetItems", array(100, 200, 300, 400) ); GUIComboBox( $ComboBox, "AddItem", 450 ); GUIComboBox( $ComboBox, "AddItems", array(500, 600, 700, "Hello") ); GUIComboBox( $ComboBox, "InsertItem", "lol", 3 ); GUIComboBox( $ComboBox, "InsertItems", array("One", "Two", "Three", "Four"), 4 ); GUIComboBox( $ComboBox, "DelItem", "Three" ); GUIComboBox( $ComboBox, "DelItemAt", 0 ); $Items = GUIComboBox( $ComboBox, "GetItems" ); foreach($Items as $i) { println("Item '$i'"); } // Add Links GUILink($ComboBox, "SelectedIndexChanged", "onChange();"); // Keep the GUI running as long as long as the window is open While ( GUIStatus( $GUI ) ) DoEvents( ); Function onChange() { my $Index = $arg[0]; my $Text = $arg[1]; println("ComboBox was clicked... Index '$Index' | Text '$Text'"); }