1. Win32Lib-Radio Buttons

I have a question about radio buttons in Win32lib.

Perhaps this is normal behavior--I'm not sure.

If you have some radio buttons under Win32lib, and the radio buttons are
children of a window, then onClick() works quite normally (ie, it is called
whenever you click on the radiobuttons).

If, however, you create a group and make the radio buttons children of the
group, the buttons seem to work fine on the screen (you can click them and
detect their state with isChecked()) but onClick() stops working for the
radio buttons.

I'm running win32lib 0.45b.

I came across this because I wanted to have two different sets of radio
buttons in one window, and I wanted to detect whenever they were
clicked.  My short=term solution is to add the BS_RADIOBUTTON flag to the
radio buttons.  This converts them from "auto" radio buttons to
"manual".  Then I take care of the details of keeping exactly one radio
button per group selected within my program.  The radiobuttons are children
of the window, so onClick works OK.

I had a look at the win32lib code, and couldn't see anything obvious that
would cause this.  Maybe it's a strange Windows behavior?

Comments welcome.

--Brent

Example (onClick works as expected)---------------------------------------

include win32lib.ew

constant

   OptionsWidth=640,
   OptionsHeight=465,
   Options = create(Window, "Options", 0,81,89,OptionsWidth, OptionsHeight,0),
   grWrong = create (Group, "Sound to Play on Wrong Answer", Options,  0,
84, 318, 220, 0),
   rbWrongWave = create (Radio, "Play Wave", Options,  2, 42 + 84 , 125,
20, 0),
   rbWrongMidi = create (Radio, "Play Midi", Options,  165, 42 + 84, 125,
20, 0)


procedure onClick_rbWrongMidi()
    print (1, 100)
end procedure

onClick[rbWrongMidi] = routine_id("onClick_rbWrongMidi")

WinMain(Options, Normal)



Example (onClick is never called)---------------------------------------

include win32lib.ew

constant

   OptionsWidth=640,
   OptionsHeight=465,
   Options = create(Window, "Options", 0,81,89,OptionsWidth, OptionsHeight,0),
   grWrong = create (Group, "Sound to Play on Wrong Answer", Options,  0,
84, 318, 220, 0),
   rbWrongWave = create (Radio, "Play Wave", grWrong,  2, 42 + 84 , 125,
20, 0),
   rbWrongMidi = create (Radio, "Play Midi", grWrong,  165, 42 + 84, 125,
20, 0)


procedure onClick_rbWrongMidi()
    print (1, 100)
end procedure

onClick[rbWrongMidi] = routine_id("onClick_rbWrongMidi")

WinMain(Options, Normal)

----------------------------------------


+++++++++++++++++++ Brent Hugh / bhugh at griffon.mwsc.edu ++++++++++++++++++
+   Missouri Western State College Dept of Music, St. Joseph, Missouri   +
+               Piano Home Page: http://www.mwsc.edu/~bhugh              +
+ Internet Piano Concert:  http://cctr.umkc.edu/userx/bhugh/recital.html +
++++++++++ Classical Piano MP3s http://www.mp3.com/brent_d_hugh ++++++++++

new topic     » topic index » view message » categorize

2. Re: Win32Lib-Radio Buttons

On Mon, 20 Dec 1999 02:05:48 -0600, Brent Hugh <bhugh at CSTP.UMKC.EDU> wrote:

>I have a question about radio buttons in Win32lib.

  Brent:

     I think that your problem is that Group is a STATIC control

     therefore it receives no events.

  Bernie

new topic     » goto parent     » topic index » view message » categorize

3. Re: Win32Lib-Radio Buttons

Brent,

I thought I would try to work around your problem by using onChange() the
radio, so you could then use isChecked on grouped Radios, but that was
worse: onChange wouldn't work on a Radio Button in a group, nor in the main
window, nor even on a regular Check Box.  Maybe onChange isn't supposed to
work with them?  But I do suspect onClick is SUPPOSED to work on Radio
Buttons in a group.  Maybe it's a Bug??  And I don't think the fact that a
group is a static control which can't receive events means that the controls
IN a group can't receive events, as that wouldn't make sense.

Dan Moyer


-----Original Message-----


>I have a question about radio buttons in Win32lib.
<snip>
>If, however, you create a group and make the radio buttons children of the
>group, the buttons seem to work fine on the screen (you can click them and
>detect their state with isChecked()) but onClick() stops working for the
>radio buttons.
>
>I'm running win32lib 0.45b.
>
>I came across this because I wanted to have two different sets of radio
>buttons in one window, and I wanted to detect whenever they were
>clicked.
<snip>
>Brent Hugh

new topic     » goto parent     » topic index » view message » categorize

4. Re: Win32Lib-Radio Buttons

Thanks to Bernie, Dan, Wolfgang Fritz and the other people who answered on
this thread, I was put onto *a* workable solution to this problem.  In the
Win32.hlp file there is this flag mentioned:

------
WS_GROUP        Specifies the first control of a group of controls. The
user can change the keyboard focus from one control in the group to the
next by using the direction keys. All controls defined with the WS_GROUP
style after the first control belong to the same group. The next control
with the WS_GROUP style ends the group and starts the next group.
------

To use this flog, you make the radio buttons children of the window (NOT of
the group--you can draw a group if you want it for looks; just don't make
the radio buttons children of it). Then in the "flags" when you create each
group of buttons, specify "WS_GROUP" for the first button of each
group.  It seems to do the trick, and since the buttons are children of the
window, their onClicks and other events work correctly.


Sample code that gives two "groups" of radio buttons in one window:

constant
   OptionsWidth=640,
   OptionsHeight=465,
   Options = create(Window, "Options", 0,81,89,OptionsWidth, OptionsHeight, 0)

constant
   rbWrongWave = createf (Radio, "Play Wave", Options,  2,   130, 125, 20,
WS_GROUP),
   rbWrongMidi = createf (Radio, "Play Midi", Options,  165, 130, 125, 20, 0),

   rbRightWave = createf (Radio, "Play Wave", Options,  92,  130, 125, 20,
WS_GROUP),
   rbRightMidi = createf (Radio, "Play Midi", Options,  235, 130, 125, 20, 0),


> >I have a question about radio buttons in Win32lib.
><snip>
> >If, however, you create a group and make the radio buttons children of the
> >group, the buttons seem to work fine on the screen (you can click them and
> >detect their state with isChecked()) but onClick() stops working for the
> >radio buttons.
> >
> >I'm running win32lib 0.45b.
> >
> >I came across this because I wanted to have two different sets of radio
> >buttons in one window, and I wanted to detect whenever they were
> >clicked.
><snip>
> >Brent Hugh



++++++++++++++++++++ Brent Hugh / bhugh at cstp.umkc.edu ++++++++++++++++++++
+        University of Missouri-Kansas City, Conservatory of Music       +
+  Sheet Music/Recordings: http://www.sunflower.org/~bhugh/pathetic.spm  +
+ Internet Piano Concert:  http://cctr.umkc.edu/userx/bhugh/recital.html +
++++++++++ Classical Piano MP3s http://www.mp3.com/brent_d_hugh ++++++++++

new topic     » goto parent     » topic index » view message » categorize

5. Re: Win32Lib-Radio Buttons

Brent Hugh wrote:


> To use this flag, you make the radio buttons
> children of the window (NOT of the group)

Sorry for being unable to help; some of this stuff remains magic to me, too.

There are other problems with making the child belong to the group. For
example, it won't properly paint itself in the parent's background color. I
tried adding a quick hack to fix that, but it's going to take some looking
at.

I'd also like to note that latest bleeding edge, v0.45e, was just posted at:

    http://www.lanset.com/dcuny/win32.htm

I had previously misreported the last bleeding edge (12/19/1999) as 0.45e.
Changes between 0.45d and 0.45e include:

    3D look to controls
    setMousePointer works with controls

As usual, bug reports are appreciated.

Thanks to all those submitting bug reports and corrections!

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu