On Jun 30, 2006, at 4:34 PM, Chuck Pelto wrote:
Hi Fargo,
On Jun 30, 2006, at 12:55 PM, Fargo Holiday wrote:
I'm certainly no expert, but couldn't you just track the change
using a global variable, which is updated via the radiobutton's
index when Action is fired? Maybe even create a method to convert
the index result to whatever data you need, then update your global
(s), and have that method called when Action fires.
That's an interesting idea, but I'm afraid it doesn't really
address the issue I'm grappling with here.
I'm trying to come up with a mechanism, i.e., a method inside of a
module, that can easily identify the field inside of a V4RB2
database that is changed as the result of someone clicking on a
RadioButton inside ANY GroupBox collection of such controls.
The concept is that every RadioButton will have a boolean field in
the V4RB2 database associated with it.
If one RadioButton is selected, i.e., set to TRUE, I can easily
capture that using the Action to call the module-method. However,
since REALbasic (RB) automatically turns the other RadioButtons in
the GroupBox to FALSE, it's not as easy as I would like to capture
those reset controls in the V4RB2 database fields associated with
them, as there is no way to easily hook into the mechanism that the
GroupBox is using, at least as far as I can determine.
I've tried the approach that Terry Ford suggested; setting the
value of a RadioButton with a line of code. But he is correct that
setting a RadioButton's value to FALSE does NOT trigger an Action
event. As a result, both boolean fields in the V4RB2 database, each
associated with one of the buttons, are now showing TRUE; which
should not be the case.
So, I guess I'll just have to knuckle down and write the necessary,
but egregious, extra lines of a loop to do something that I am
confident, REALSoft can build into RB in the, hopefully, not too
distant future; a means to call Actions and/or a call to a GroupBox
that will return the caption of the selected RadioButton.
Calling event handlers from outside the object would be a very bad
idea. Writing such a function that acts on GroupBoxes is trivial and
it doesn't make sense for RS to add such a specialized thing.
However, I'm open to other suggestions on how to skin this
particular cat.
Add the following method to a module.
Function RadioButtonState(box as GroupBox) As Dictionary
If box is nil or box.Window is nil then
Return new Dictionary
End if
dim d as new Dictionary
For i as Integer = 0 to box.Window.ControlCount - 1
If box.Window.Control(i) IsA RectControl and RectControl
(box.Window.Control(i)).Parent is box and box.Window.Control(i) IsA
RadioButton then
d.Value(box.Window.Control(i).Name) = RadioButton
(box.Window.Control(i)).Value
End if
Next
Return d
End Function
Using this function, you can get the state of all RadioButtons in a
GroupBox from the Action event handler of any RadioButton.
Sub Action()
If not (me.Parent IsA GroupBox) then
Return
End if
dim d as Dictionary = RadioButtonState(GroupBox(me.Parent))
//write state to database
End Sub
Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>