[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Proxy for RadioButton


On 21/9/24 8:26 pm, Bruce Steers wrote:

Here is a similar thing but in RadioButton.class auto-inheritance

The following text is saved as RadioButton.class in .src folder

It exposes the Action property to the IDE (not for this use but i did it anyway)

It more importantly adds an ActWith property to RadioButton

If set all other radios sharing the ActWith property name will set to false when clicking one.
and it stops user being able to deselect by click so none are selected.
The ActWith name can be anything you want.

Have fun :)

BruceS
------------------------------
' Gambas class file

Export

Public Const _Properties As String = "*,Action,ActWith"

'' Use this to have singular RadioButton Have a Parent.\
'' All RadioButtons sharing the same ActWith name are linked like they are in the same parent container.
Property ActWith As String Use $sActWith

Private $hObs As Observer

Public Sub _new()

  $hObs = New Observer(Me) As "OBS"

End

'' Check all window controls to see if they are radio buttons sharing the same ParentGroup
Public Sub OBS_Click()

  If Not $sActWith Then Return

  For Each hObj As Object In Me.Window.Controls
    If hObj Is RadioButton Then
      If hObj.ActWith <> Last.ActWith Then Continue
      If hObj.name <> Last.Name And If hObj.Value Then
        Object.Lock(hObj)
        hObj.Value = False
        Object.UnLock(hObj)
      Endif
    Endif
  Next

End

'' Stop the user setting Value to false by clicking
Public Sub OBS_MouseUp()

  If Not $sActWith Then Return

  If Not Last.ActWith Then Return
  If Last.Value Then Stop Event

End
-------------------------------------

That is starting to look good. I'll check it out tomorrow.

Also, I've been thinking that maybe I'm thinking about this upside down. Maybe I should be thinking about the container, not the radioButton. But it's just a think.

(My head hurts)

b


Follow-Ups:
Re: Proxy for RadioButtonBruce Steers <bsteers4@xxxxxxxxx>
References:
Proxy for RadioButtonBB <adamnt42@xxxxxxxxx>
Re: Proxy for RadioButtonJussi Lahtinen <jussi.lahtinen@xxxxxxxxx>
Re: Proxy for RadioButtonBB <adamnt42@xxxxxxxxx>
Re: Proxy for RadioButtonBruce Steers <bsteers4@xxxxxxxxx>
Re: Proxy for RadioButtonBruce Steers <bsteers4@xxxxxxxxx>