Changes between Version 1 and Version 2 of UserGuide/Lua
- Timestamp:
- Oct 8, 2016, 12:53:33 PM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
UserGuide/Lua
v1 v2 132 132 133 133 * {{{inputbox(window_title,label_1,initial_value_1,min_1,max_1,digits_1,...)}}} Opens a window that asks the user for one or several setting values. The control only accepts values between the min and max that you provide, and you can specify how many decimal places of precision it should have with {{{digits}}}. You can ask for more than one value by adding arguments: label_2, initial_value_2, min_2, max_2, digits_2 etc, with a limit of 9 settings. This function returns one value to tell if the user accepted or cancelled (true or false), and one additional return value by setting. Example: 134 {{{ 134 135 {{{#!lua 135 136 ok, w, h = inputbox("Modify brush size", 136 137 "Width", w, 1,100,0, … … 138 139 ); 139 140 }}} 141 140 142 * If min and max are 0 and 1, and digits is 0, it will show a checkbox. Ex: 141 {{{ 143 {{{#!lua 142 144 ok, xflip, yflip = inputbox("Transformation", 143 145 "X-Flip", 0, 0, 1,0, … … 145 147 ); 146 148 }}} 149 147 150 * If min and max are 0 and 1, and digits is negative, it will show a radio button. Radio buttons with the same number of "digits" are grouped together. Ex: 148 {{{ 151 {{{#!lua 149 152 ok, a, b ,c, d = inputbox("Your choice", 150 153 "A", 1, 0, 1,-1, … … 154 157 ); 155 158 }}} 159 156 160 * If min and max are 0, the entry is just a label, the user can't input anything on this line. 157 161 158 162 * {{{selectbox(caption,label_1,callback_1,label_2,callback_2)}}} Opens a window where the user has to click on one of the buttons. You provide the button labels, and Grafx2 executes the associated callback, which must be a function : a pre-defined function (don't type the parentheses after function name) or an anonymous function that you build on the spot. The user can press Esc to cancel. Example: 159 {{{ 163 {{{#!lua 160 164 selectbox("Menu", 161 165 "Sub-menu 1", sub_menu1_func, … … 195 199 Here is a very small sample script that generate a diagonal gradient. 196 200 197 {{{ 201 {{{#!lua 198 202 -- get the size of the brush 199 203 w, h = getbrushsize() … … 225 229 * Memory.lua : persistent on-disk storage for your scripts. Use this for storing your own settings or other data. 226 230 227 We welcome any additions you want to make to this set of functions. If something proves too slow when done in lua, we may provide a faster C version, with the same interface whenever possible. This way all scripts can share the enhancements. 231 We welcome any additions you want to make to this set of functions. If something proves too slow when done in lua, we may provide a faster C version, with the same interface whenever possible. This way all scripts can share the enhancements.º