====== Input GUI Widgets I ====== ---- ===== Input GUI Class ===== ---- [[https://github.com/LibreCAD/LibreCAD_3/blob/master/lcUI/widgets/guiAPI/inputgui.h|Github Link]] namespace lc::ui::api The Input GUI class is the parent class of all input gui widgets (except button and checkbox) which is added to the dialog widget. This is an abstract class. ---- ==== Label ==== ---- === Description === Get and set label for the Input GUI widget. === Examples === * message(input1:label()) * input1:setLabel("New Input GUI") ---- ==== Enable and Disable ==== ---- === Description === Enable or disable the input gui widget. === Examples === * input1:enable() * input1:disable() ---- ===== Angle GUI Class ===== ---- [[https://github.com/LibreCAD/LibreCAD_3/blob/master/lcUI/widgets/guiAPI/anglegui.h|Github Link]] namespace lc::ui::api The Angle GUI class is used to enter an angle. Angle can be toggled between radians and degrees by clicking on the Rad/Deg button or by using the appropriate functions. Needs to be added to the dialog widget to be used. ---- ==== Constructor ==== ---- === Description === Constructs an angle gui widget. === Examples === * local angle1 = gui.Angle("Angle1") ---- ==== Get and Set Values ==== ---- === Description === Used to get the current value of the angle widget or set it to a desired value. //Note:- Always returns and expects the value to be in **RADIANS** . If the current display mode is in degrees, the angle is converted to degrees and displayed. When retrieving the mode dosen't matter, always returns in radians.// === Examples === * local val = angle1:value() * angle1:setValue(1.56) ---- ==== To Degrees ==== ---- === Description === Used to switch the display mode to degrees, if the value is in radians it is automatically converted and shown in degrees. === Examples === * angle1:toDegrees() ---- ==== To Radians ==== ---- === Description === Used to switch the display mode to radians, if the value is in degrees it is automatically converted and shown in radians. === Examples === * angle1:toRadians() ---- ==== Add Finish Callback ==== ---- === Description === Add a finish callback which is called when the user presses enter after entering the angle or clicks somewhere else and the input gui loses focus. This is different from the dialog widget finish callback. === Examples === * angle1:addFinishCallback(function() message("Finished typing angle") end) ---- ==== Add On Change Callback ==== ---- === Description === Add an on change callback which is called when the user types anything i.e. on any change to the input. === Examples === * angle1:addOnChangeCallback(function() message(tostring(angle1:value())) end) ---- ===== Button GUI Class ===== ---- [[https://github.com/LibreCAD/LibreCAD_3/blob/master/lcUI/widgets/guiAPI/buttongui.h|Github Link]] namespace lc::ui::api The Button GUI class is used to add a button to the dialog widget. Callbacks can be added to the button which is called when the button is clicked. ---- ==== Constructor ==== ---- === Description === Constructs an button gui widget === Examples === * local button1 = gui.Button("button1") ---- ==== Add Callback ==== ---- === Description === Add a callback to be called whenever the user clicks on the button. === Examples === * button1:addCallback(function() message("Button Clicked") end) ---- ===== RadioButton GUI Class ===== ---- [[https://github.com/LibreCAD/LibreCAD_3/blob/master/lcUI/widgets/guiAPI/radiobuttongui.h|Github Link]] namespace lc::ui::api The RadioButton GUI class is used to add a RadioButton to a radio group of the dialog widget. Callbacks can be added to the button which is called when the radiobutton is checked. ---- ==== Constructor ==== ---- === Description === Constructs a radiobutton gui widget. === Examples === * local radio1 = gui.RadioButton("radio1") ---- ==== Add Callback ==== ---- === Description === Add a callback to be called whenever the user clicks on the button toggling it's checked state. === Examples === * radio1:addCallback(function(toggled) message(tostring(toggled)) end) ---- ==== Checked and Set Checked ==== ---- === Description === Used to get and the set the value of the radio button i.e. toggle the checked state of the radio button. === Examples === * local val = radio1:checked() * radio1:setChecked(false) ---- ===== Checkbox GUI Class ===== ---- [[https://github.com/LibreCAD/LibreCAD_3/blob/master/lcUI/widgets/guiAPI/checkboxgui.h|Github Link]] namespace lc::ui::api The Checkbox GUI class is used to add a checkbox to the dialog widget. Callbacks can be added to the checkbox which is called when the checkbox is checked or unchecked. ---- ==== Constructor ==== ---- === Description === Constructs an checkbox gui widget === Examples === * local check1 = gui.CheckBox("check1") ---- ==== Add Callback ==== ---- === Description === Add a callback to be called whenever the user checks or unchecks the checkbox.Passes in a bool representing whether the button is checked or not. === Examples === * check1:addCallback(function(checked) message("Checkbox is checked - " .. tostring(checked)) end) ---- ==== Set checked and Is checked ==== ---- === Description === Check if the checkbox is checked or set the checkbox to be checked/unchecked. === Examples === * local isChecked = check1:checked() * check1:setChecked(true) ---- ===== ComboBox GUI Class ===== ---- [[https://github.com/LibreCAD/LibreCAD_3/blob/master/lcUI/widgets/guiAPI/comboboxgui.h|Github Link]] namespace lc::ui::api The ComboBox GUI class is used to add a combobox to the dialog widget. Callbacks can be added to the checkbox which is called when a element is selected, the name of the selected element is passed as a parameter to the callback. ---- ==== Constructor ==== ---- === Description === Constructs an combobox gui widget === Examples === * local combo1 = gui.ComboBox("combo1") ---- ==== Add Callback ==== ---- === Description === Add a callback to be called whenever selects an element from the combobox.Passes in a string representing the name of the selected element in the combobox. === Examples === * combo1:addCallback(function(selected) message("Selected Element - " .. tostring(selected)) end) ---- ==== Get and Set Values ==== ---- === Description === Used to get the current element string of the combobox widget or set it to a desired element. If the user attempts to set an element that does not exist in the combobox, nothing happens. Element can also be set by specifying the index of the element to be selected. === Examples === * local val = combo1:value() * combo1:setValue("Element1") * combo1:setValue(0) ---- ==== Add Item ==== ---- === Description === Add an item to the combobox, if index is not specified it is added to the end of the combobox list. === Examples === * combo1:addItem("Element1", 2) * combo1:addItem("Element2") ----