Radiobuttons do not work

  1. 2 weeks ago

    Aaron H

    May 19 Testers Europe (Germany)
    Edited 2 weeks ago

    I have 2 RadioButtons in a GroupBox, in a Sheet window. The buttons do not turn each other off.

    • controls are not touching / overlapping
    • the GroupBox IS in fact the parent of both buttons

    I click one button, the other one is supposed to turn off. It doesn't.

    [EDIT: added info:

    • initial states in the IDE for both buttons: unchecked
    • putting the buttons on a canvas or empty label doesn't change anything
    • changing the window type does nothing
    • putting the buttons in a control group changes nothing
    • happens both in DebugBuild and in the built app]

    I forced the value of the other button to not me.value in the Action event of both buttons. Does nothing. I put a condition there, to only change it if the value it not the opposite. Nothing.

    Then I found out, if I show a MessageBox in the Action event, when a RadioButton is clicked, then it works. Which suggests it's just a window redraw issue. [Also if I toggle away from the app and back, it's then displayed correctly.] So, I tried forcing a window redraw of the window with self.Invalidate. That does nothing. I tried Invalidate on all the controls in the action event. Nothing. I put the invalidates in the action event of a PushButton and after both radiobuttons show ON, clicked that pushbutton like a hamster on cocaine. After a random number of clicks on this pushbutton - could be 3 or could be 6 billion - the buttons finally refresh and display correctly. [Also just noticed that once both buttons are ON, if I then simply do nothing, after a while sometimes there is a random magical window refresh, and the correct button states are finally displayed.] Excuse me, but how idiotic is this?

    MacOS 10.13.8, Xojo2019r1.1

    I think I solved it ...

    The cause appears to be MIDI callback functions (MBS plugin) firing in the main window, which trigger drawing updates in that window. Once the other window gets redrawn, the RadioButtons in the other window don't work. A workaround appears to be: turn off the MIDI callbacks while showing the second window.

    Is there any logical explanation for this? Seems like: MIDI callbacks get system priority, and interrupt whatever is going on in the other window, breaking RadioButton behaviour.

  2. Greg O

    May 19 Xojo Inc scout.galaxy.barn

    Do you have the same issues with the radio buttons in the Xojo preferences dialog?

  3. Aaron H

    May 19 Testers Europe (Germany)
    Edited 2 weeks ago

    @Greg OLone Do you have the same issues with the radio buttons in the Xojo preferences dialog?

    Nope, all of those work fine.

    Also forgot to mention, I did try changing the window type, from sheet to document. No difference.

    There is also no code setting the values of the RadioButtons, except immediately when the window opens.

  4. Greg O

    May 19 Xojo Inc scout.galaxy.barn

    @Aaron H Nope, all of those work fine.

    Also forgot to mention, I did try changing the window type, from sheet to document. No difference.

    In that case it would be helpful to see an example project as the IDE isn’t doing any magic there.

  5. Don L

    May 19 Xojo Pro Florence, South Carolina USA

    This may be a stupid question, but since I don't know your level of Xojo experience and I don't see this in the 3 bulleted items you point out that you did, I'll ask it anyways just in case ... did you set the radio buttons up as members of a control set?

    i.e.,

    rbnChoice(0)
    rbnChoice(1)

  6. Aaron H

    May 19 Testers Europe (Germany)
    Edited 2 weeks ago

    @Don L This may be a stupid question, but since I don't know your level of Xojo experience and I don't see this in the 3 bulleted items you point out that you did, I'll ask it anyways just in case ... did you set the radio buttons up as members of a control set?

    i.e.,

    rbnChoice(0)
    rbnChoice(1)

    Initially the two buttons were not a control set, so I did that. No difference. (forgot to put that in my bullet list.) But in fact making them a control set should not be necessary. If I make a test project, just drag 2 RadioButtons onto a window and run the project, they turn each other off. So there's something really wrong going on in this window.

  7. Aaron H

    May 19 Testers Europe (Germany)
    Edited 2 weeks ago

    @Greg OLone In that case it would be helpful to see an example project as the IDE isn’t doing any magic there.

    A test project doesn't show the problem. It's only happening in this one window in this project. I've never seen this happen before either.

  8. Aaron H

    May 19 Testers Europe (Germany)
    Edited 2 weeks ago

    ... I just noticed that once both buttons are ON, if I then simply do nothing, after a while sometimes there is a random magical window refresh, and the correct button states are finally displayed.

    Also, if I toggle away from the app and back, it's then displayed correctly.

  9. Aaron H

    May 19 Testers Answer Europe (Germany)
    Edited 2 weeks ago

    I think I solved it ...

    The cause appears to be MIDI callback functions (MBS plugin) firing in the main window, which trigger drawing updates in that window. Once the other window gets redrawn, the RadioButtons in the other window don't work. A workaround appears to be: turn off the MIDI callbacks while showing the second window.

    Is there any logical explanation for this? Seems like: MIDI callbacks get system priority, and interrupt whatever is going on in the other window, breaking RadioButton behaviour.

  10. Emile S

    May 19 Europe (France, Strasbourg)

    @Aaron H I just noticed that once both buttons are ON

    This is not meant to happening. More than one CheckBox can be set to ON, but not RadioButtons.

    Try to set all RadioButtons to OFF (at design time).

  11. Tim H

    May 19 Portland, OR USA

    @Don L This may be a stupid question, but since I don't know your level of Xojo experience and I don't see this in the 3 bulleted items you point out that you did, I'll ask it anyways just in case ... did you set the radio buttons up as members of a control set?

    i.e.,

    rbnChoice(0)
    rbnChoice(1)

    Just fyi, having the radiobuttons in a control set is irrelevant to them functioning as a group. That is based purely on the Parent of the radiobuttons. So you could actually have buttons from the same control set operating independently in separate groups.

or Sign Up to reply!