Re: Custom radio button failure with bindings [Solved]
Re: Custom radio button failure with bindings [Solved]
- Subject: Re: Custom radio button failure with bindings [Solved]
- From: Ricky Sharp <email@hidden>
- Date: Fri, 25 Feb 2005 12:23:18 -0600
On Feb 22, 2005, at 12:47 PM, Ricky Sharp wrote:
I'm now replacing one standard item at a time with my custom item to
ensure that bindings behave as expected. I'm running into a problem
with a custom NSMatrix (IIRadioGroup) containing my own radio buttons
(instances of IIButtonCell).
I've bound selectedIndex of the matrix to my model. When full
keyboard access is used to move the amongst the radio buttons, the
value in my model changes as expected. If I click on the radio
button, it does become the new selected cell (previous one is
deselected as expected), but my model isn't updated.
In IIRadioGroup, I do provide an override to mouseDown. I needed to
do this in order to provide the same user experience with my custom
radio buttons as they'd get with the standard buttons.
In my mouseDown, when a cell ultimately needs to be selected, I use
selectCell. I also tried using selectCellWithTag. Both do select the
appropriate cell, but my model isn't updated. This leads me to
believe that such a change isn't being observed. But why? Is
interacting with the keyboard ultimately calling some internal private
method of NSMatrix to change the selection which is in turn observed
by the bindings system? Shouldn't selectCell, selectCellWithTag, etc.
all bottleneck through a common routine which will change a value that
is observed?
Now that I understand bindings much better, I was able to rework my
IIButton/IIButtonCell combo to work correctly with IIRadioGroup
(subclass of NSMatrix).
From what I've found, it's not really possible to "half-way" use
inherited bindings. What I mean by this is that IIRadioGroup was using
the NSMatrix implementation of keyDown: and reflecting the change to
bindings such as selectedIndex and selectedTag. But because I needed
to provide my own mouseDown:, I ultimately couldn't set up
view-initiated changes to selectedIndex, selectedTag, etc from within
my code (at least I couldn't find a way to do that).
So, I came up with my own binding, selectedRadioTag. I now provide an
override to keyDown: in IIRadioGroup which does this:
- obtain the current selected cell; mark as old cell
- super keydown
- obtain the current selected cell; mark as new cell
- if new != old, set a view-initiated change to the selectedRadioTag
property
mouseDown: also does a view-initiated change to that property if the
mouse is released within the frame of a non-selected radio button.
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden