User Guide

Ruby Component
Controls and Dialogs
There a few user interface elements that we use Windows controls and dialogs for. We have primitives for these but when you're
programming an interface using Ruby components it's far easier to be able to access them from with your code.
This section describes these elements and how to use them.
In Place Edit Controls
Edit controls are pretty much essential for gathering precise numerical or text input. You can create an in place edit control on-the-fly
whenever you need to get information by using the createEdit method:
createEdit input, id, area, [startText [,font [,textColour [,backColour [,multiline]]]]]
The inputs to the method are as follows:
input - reference to the input View connector (name or index)
id - an id that you can use on the callback so you know which edit is reporting
area - four element array [x,y,w,h] to define position and size
startText - the text that will show in the edit to start with [OPTIONAL]
font - the font to use (a font object) [OPTIONAL]
textColour - the colour of the text [OPTIONAL]
backColour - the colour of the background rectangle for the edit control [OPTIONAL]
multiline - whether the control should be a multiline edit (true or false) [OPTIONAL]
Once the edit control is created it will report back to the Ruby component. You can capture the reported information by implementing one or
both of the following methods:
def editFinished id,text
end
def editChanged id,text
end
The inputs to these methods are the same – the id of the edit control that is reporting (the one you supplied when you created it) and the text
that is currently in the control. The only difference between the two is that the editChanged method is called with every keystroke whereas
the editFinished method is only called when the edit control is closed (when the user presses tab or clicks away).
Here's an example of an in place edit control being used to capture input. In this example we've clicked on the UI so the mouseLDown
method has already been called and created the edit control.
153 of 212