I'm having difficulty working with bindings and I'm not sure if it's a MacRuby thing or my poor understanding of how they work.

I've tried binding to two types of things - an NSMatrix of radio buttons (binding to "selectedTag") and a Checkbox value.

Using just an attr_accessor - the variable changes when the user changes them, but changing the variable doesn't update in the UI.

So I added an explicit setter method and to change the variable, I use self.setVideoSource(VID_USE_S2) to modify it.

This works to change it on-screen, but now UI changes aren't getting through to the variables properly. The NSMatrix variable isn't changing, and the other variables are changing but are no longer Boolean. (If I do a "p x" I get either #<NSCFBoolean:0xa07f13f8> or #<NSCFBoolean:0xa07f1400>.

I tried replacing 'attr_accessor' with 'attr_reader', and adding an explicit getter. That results in the following when I run (even if I add a 'return nil' to my setter method):

[4169:10b] KVO autonotifying only supports -set<Key>: methods that return void. Autonotifying will not be done for invocations of - [MainWinController setVideoSource:].

I haven't yet tried manual notification because I'm not likely to use bindings for this case if that much work is required. Is this the expected way to go, or am I missing something here?



Here's a bit of the code (these are set as keys in IB). When used elsewhere, I just have them as the instance variable :

attr_accessor   :audioIncludeS1         # whether to include audio
attr_accessor   :audioIncludeS2         # for a particular channel
attr_accessor           :videoSource            # which source to use (if any) 
for video
        
def setAudioIncludeS1(value)
    @audioIncludeS1 = value
end

def setAudioIncludeS2(value)
    @audioIncludeS2 = value
end


def setVideoSource(value)
    case value
        when VID_USE_S1
            @videoSource = VID_USE_S1
        when VID_USE_S2
            @videoSource = VID_USE_S2
        when VID_USE_NONE
            @videoSource = VID_USE_NONE
        else
            @videoSource = VID_USE_NONE
    end
end

_______________________________________________
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

Reply via email to