New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically initializing a Radio Button #6

Closed
ccoupe opened this Issue Dec 23, 2014 · 8 comments

Comments

Projects
None yet
2 participants
@ccoupe
Contributor

ccoupe commented Dec 23, 2014

@ccoupe ccoupe added the OSX label Dec 24, 2014

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Mar 16, 2015

Contributor

Editted : Mar 16, 2014
There are several issues with Radio buttons.

Shoes.app do
  stack do
    flow {
      @r1 = radio :group, checked: true
      para "one"
    }
    flow {@r2 = radio :group; para "two"}
    para "================"
    flow { # horizontal grouping
      @r3 = radio :newgrp; para "near"
      @r4 = radio :newgrp; para "far"
    }
    @r4.checked = true 
    start { 
      para "checked one = #{@r1.checked?}\n" 
      para "checked far = #{@r4.checked?}\n"
    }
    button "Now check" do
      para "One: #{@r1.checked?}\n"
      para "Two: #{@r2.checked?}\n"
      para "near: #{@r3.checked?}\n"
      para "far: #{@r4.checked?}\n"
    end
  end
end

OSX lumps all radios into one group. Cocoa is not told to use different groups. But, ruby.c attempts to to manage it ( #define FORCE_RADIO).

It may not be possible to have more than one radio group per window on OSX. Groups need NSRadioMatrix handling which assume you know the NSRect which Shoes doesn't know and the matrix dimensions which we also don't know. Can it all be dynamically adjusted? Probably. Easy? No.

One other problem: On OSX, The start {} doesn't display until the button is pushed. That might be an unrelated bug.

Contributor

ccoupe commented Mar 16, 2015

Editted : Mar 16, 2014
There are several issues with Radio buttons.

Shoes.app do
  stack do
    flow {
      @r1 = radio :group, checked: true
      para "one"
    }
    flow {@r2 = radio :group; para "two"}
    para "================"
    flow { # horizontal grouping
      @r3 = radio :newgrp; para "near"
      @r4 = radio :newgrp; para "far"
    }
    @r4.checked = true 
    start { 
      para "checked one = #{@r1.checked?}\n" 
      para "checked far = #{@r4.checked?}\n"
    }
    button "Now check" do
      para "One: #{@r1.checked?}\n"
      para "Two: #{@r2.checked?}\n"
      para "near: #{@r3.checked?}\n"
      para "far: #{@r4.checked?}\n"
    end
  end
end

OSX lumps all radios into one group. Cocoa is not told to use different groups. But, ruby.c attempts to to manage it ( #define FORCE_RADIO).

It may not be possible to have more than one radio group per window on OSX. Groups need NSRadioMatrix handling which assume you know the NSRect which Shoes doesn't know and the matrix dimensions which we also don't know. Can it all be dynamically adjusted? Probably. Easy? No.

One other problem: On OSX, The start {} doesn't display until the button is pushed. That might be an unrelated bug.

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Mar 18, 2015

Contributor

ruby.c handles the groups and setting the buttons off and on just fine. It's osx that thinks all buttons without a matrix must be in a hidden matrix. One hack worth trying: Creating an explicit NSMatrix with 1 row, 1 column for each Shoes radio button so that osx won't manage them all collectively. Odd thinking but it might work.

Contributor

ccoupe commented Mar 18, 2015

ruby.c handles the groups and setting the buttons off and on just fine. It's osx that thinks all buttons without a matrix must be in a hidden matrix. One hack worth trying: Creating an explicit NSMatrix with 1 row, 1 column for each Shoes radio button so that osx won't manage them all collectively. Odd thinking but it might work.

ccoupe added a commit that referenced this issue Mar 20, 2015

towards a #6 solution. Not perfect, still wrong
but better from OSX pov - needs -DNEW_RADIO to enable. Lots of
NSLog stuff because I have no idea what I'm doing. OK, a small idea.

ccoupe added a commit that referenced this issue Mar 23, 2015

Backing up on #6. Remove NSMatrix experiment. Toxic
* Radio are now shown as checkboxes but act like radios when
in a group (there is a default group).
* Radios have their own Cocoa subclass of NSButton.
* Will have to implement code to draw them so they don't look like checkboxes.
* start {} in bug006.rb still doesn't work like gtk.
* As radio buttons it does work as expected.  Just look wrong.
@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Mar 23, 2015

Contributor

This is a nasty problem. The semantic mismatch between OSX radios and Shoes radios is high. No wonder it was never fixed. Still isn't. Shoes treats radios just like checkboxes and Shoes manages the groups on/off settings. OSX radiobuttons assume there is a NSMatrix that will manage them and misbehave if there isn't. Radio buttons in Shoes are pretty clunky (as are checkboxes) but solving that breaks backwards compatibility so that's a different issue than this bug report.

Contributor

ccoupe commented Mar 23, 2015

This is a nasty problem. The semantic mismatch between OSX radios and Shoes radios is high. No wonder it was never fixed. Still isn't. Shoes treats radios just like checkboxes and Shoes manages the groups on/off settings. OSX radiobuttons assume there is a NSMatrix that will manage them and misbehave if there isn't. Radio buttons in Shoes are pretty clunky (as are checkboxes) but solving that breaks backwards compatibility so that's a different issue than this bug report.

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Mar 23, 2015

Contributor

The radio buttons need new images so they look more like OSX radios but the style below should be good enough for a while.
temp-radio

Also the start {} block messages show up if the screen is resized so the block does execute at the correct time - just needs to trigger a redraw.

Contributor

ccoupe commented Mar 23, 2015

The radio buttons need new images so they look more like OSX radios but the style below should be good enough for a while.
temp-radio

Also the start {} block messages show up if the screen is resized so the block does execute at the correct time - just needs to trigger a redraw.

@ccoupe ccoupe added this to the 3.2.22 milestone Mar 23, 2015

@BackOrder

This comment has been minimized.

Show comment
Hide comment
@BackOrder

BackOrder Mar 23, 2015

Collaborator

Is that normal the radio and para are misaligned vertically?

Collaborator

BackOrder commented Mar 23, 2015

Is that normal the radio and para are misaligned vertically?

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Mar 23, 2015

Contributor

I haven't committed the code changes yet - its just a BezelStyle setting. They need to be drawn with NSImages which I haven't created (or borrowed).

Contributor

ccoupe commented Mar 23, 2015

I haven't committed the code changes yet - its just a BezelStyle setting. They need to be drawn with NSImages which I haven't created (or borrowed).

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Mar 24, 2015

Contributor

For comparison, here's the old radios CFLAGS << ' -DOLD_RADIO'
old-radios

Contributor

ccoupe commented Mar 24, 2015

For comparison, here's the old radios CFLAGS << ' -DOLD_RADIO'
old-radios

ccoupe added a commit that referenced this issue Mar 24, 2015

Switch from #ifdef NEW_RADIO to OLD_RADIO for #6
It's good enough to be the default considering how miserable the old
radio behaviour was. Now we have groups that work and buttons that don't
spit out invalid surface error messages on the console.

It's not completely fixed until I have images with a little white dot
in the blue circle.
@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Mar 24, 2015

Contributor

Considering this note that Apple is deprecating/planning to deprecate NSCell and NSMatrix https://developer.apple.com/library/mac/releasenotes/AppKit/RN-AppKit/, It may not be worth the effort to draw the icon with the tiny white dot in the center.

Contributor

ccoupe commented Mar 24, 2015

Considering this note that Apple is deprecating/planning to deprecate NSCell and NSMatrix https://developer.apple.com/library/mac/releasenotes/AppKit/RN-AppKit/, It may not be worth the effort to draw the icon with the tiny white dot in the center.

@ccoupe ccoupe closed this Mar 27, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment