Skip to content
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
Closed

Automatically initializing a Radio Button #6

ccoupe opened this issue Dec 23, 2014 · 8 comments
Labels
Milestone

Comments

@ccoupe
Copy link

ccoupe commented Dec 23, 2014

Was shoes/shoes-deprecated#167

@ccoupe ccoupe added the OSX label Dec 24, 2014
@ccoupe
Copy link
Author

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
Copy link
Author

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 pushed a commit that referenced this issue Mar 20, 2015
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 pushed a commit that referenced this issue Mar 23, 2015
* 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
Copy link
Author

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
Copy link
Author

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
@IanTrudel
Copy link
Collaborator

Is that normal the radio and para are misaligned vertically?

@ccoupe
Copy link
Author

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
Copy link
Author

ccoupe commented Mar 24, 2015

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

ccoupe pushed a commit that referenced this issue Mar 24, 2015
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
Copy link
Author

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 as completed Mar 27, 2015
ccoupe pushed a commit that referenced this issue Feb 15, 2019
* still have some debugging printfs
* OSX is not and may never work correctly
ccoupe pushed a commit that referenced this issue Feb 17, 2019
* needs cosmetic fix - needs button image
ccoupe pushed a commit that referenced this issue Feb 20, 2019
ccoupe pushed a commit that referenced this issue Feb 21, 2019
* update Changelog and manual
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants