Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Radio Buttons in NSMatrix not behaving

Radio Buttons in NSMatrix not behaving
Thread Tools
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Apr 24, 2002, 02:02 PM
 
In an application I am writing I have an NSMatrix with 3 radio buttons in it. If someone clicks on any of them, I need the target to decide if they are allowed to take that action and set the NSMatrix back to its original selection if they are not allowed.

To do this, I tagged the cells in the NSMatrix 0, 1, 2. Then I receive the click and check to see if they clicked 2 ([[sender selectedCell] tag] == 2). If this is true I try to reselect 0 ([sender selectCellWithTag:0]) but this doesn't really work. If I ask the matrix what is selected right after I tell it to select 0 then it tells me that 0 is selected, however, the appearance of the NSMatrix in the UI implies that 2 is still selected.

Can anyone figure out why such odd behavior is being observed?

Thanks,
Jeff.
Spectral Class
"Shedding Light on Innovation"
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Apr 24, 2002, 04:24 PM
 
I usually do this:

<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
[matrix selectCellAtRow:rowNumber column:<font color = blue>0</font>];
</font>[/code]

Works for me everytime.

F-bacher
     
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Apr 24, 2002, 05:14 PM
 
That still doesn't work. I really don't understand why I would be having this problem. The object for the NSMatrix claims that it has selected the appropriate button but visually I can tell that it has not.

I tried your suggestion as well as setting the cell at that location to a non-zero state. Still nothing is changing.

Any other ideas?
Jeff.
Spectral Class
"Shedding Light on Innovation"
     
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Apr 25, 2002, 01:29 AM
 
I was sort of able to find a way around this problem but I still don't really understand why it happened in the first place.

I am able to do what I was trying to do only if the NSMatrix is in "Highlight" or "List" modes. In "Radio" or "Track" it doesn't work. I still don't know why the selection can't be set programmatically in those modes but I am moving on without that knowledge (unless someone knows it off the top of their head and can post it here).

So, long story short, if you need to programmatically set the selection in an NSMatrix, use Highlight mode (if you need multiple selection) or List mode (if you don't want multiple selection).

Thanks for your input,
Jeff.
Spectral Class
"Shedding Light on Innovation"
     
Junior Member
Join Date: Mar 2001
Status: Offline
Reply With Quote
Apr 25, 2002, 05:46 AM
 
I'm guessing that you just need to call one of the display methods on the matrix after changing the state (eg. setNeedsDisplay: YES).
     
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Apr 25, 2002, 12:54 PM
 
No, that is the first thing that I tried. I am getting used to most of cocoa's quirks so I know that display instructions are often the culprit. Good suggestion but it didn't help me out.

Jeff.
Spectral Class
"Shedding Light on Innovation"
     
Junior Member
Join Date: Mar 2001
Status: Offline
Reply With Quote
Apr 25, 2002, 07:54 PM
 
You should probably file a bug report on this.
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Apr 25, 2002, 08:27 PM
 
Why not get a reference to the cell at the index you want and call setState:1 off of it?

F-bacher
     
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Apr 26, 2002, 12:53 AM
 
That was another thing that I tried. It didn't work either. For some reason this seems to need the mode set to one of these settings in order to work.

Jeff.
Spectral Class
"Shedding Light on Innovation"
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:53 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2