bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bindings only working in one direction


From: Andy Balholm
Subject: Re: Bindings only working in one direction
Date: Tue, 23 Jun 2009 08:01:54 -0700

In Cocoa, the action seems to be sent when the control loses focus or Enter is pressed, regardless of whether the value has actually changed.

In Interface Builder, I made a window with two text fields and a slider. Each text field's action is set to takeIntegerValueFrom: and its target is the slider. If I put 0 in one field and 100 in the other, the slider moves back and forth as I click on the two fields.

Updating the value for a binding, on the other hand, is called from - [NSTextField textShouldEndEditing:]. The value is updated only if the contents of the field have actually changed. I got the following stack trace by binding to a custom class whose setter always crashes:

#0      0x90e7abfa in _objc_error
#1      0x90e7ac30 in __objc_error
#2      0x90e79637 in _freedHandler
#3      0x00001f7f in -[BadSetter setValue:] at BadSetter.m:24
#4      0x909565f4 in _NSSetIntValueAndNotify
#5      0x9089f257 in _NSSetUsingKeyValueSetter
#6      0x9089ecee in -[NSObject(NSKeyValueCoding) setValue:forKey:]
#7      0x909237c1 in -[NSObject(NSKeyValueCoding) setValue:forKeyPath:]
#8 0x94828441 in -[NSBinder _setValue:forKeyPath:ofObject:mode:validateImmediately:raisesForNotApplicableKeys:error :]
#9      0x948281f2 in -[NSBinder setValue:forBinding:error:]
#10 0x94827e8b in -[NSValueBinder _applyObjectValue:forBinding:canRecoverFromErrors:handleErrors:typeOfAlert:discardEditingCallback:otherCallback:callbackContextInfo:didRunAlert :] #11 0x94827b19 in -[NSValueBinder applyDisplayedValueHandleErrors:typeOfAlert:canRecoverFromErrors:discardEditingCallback:otherCallback:callbackContextInfo:didRunAlert :] #12 0x9482a86e in -[NSValueBinder _applyDisplayedValueIfHasUncommittedChangesWithHandleErrors:typeOfAlert:discardEditingCallback:otherCallback:callbackContextInfo:didRunAlert :] #13 0x948273fa in -[NSValueBinder validateAndCommitValueInEditor:editingIsEnding:errorUserInterfaceHandled :] #14 0x948271b7 in -[_NSBindingAdaptor _validateAndCommitValueInEditor:editingIsEnding:errorUserInterfaceHandled:bindingAdaptor :] #15 0x948270ef in -[_NSBindingAdaptor validateAndCommitValueInEditor:editingIsEnding:errorUserInterfaceHandled :]
#16     0x946f9eb1 in -[NSTextField textShouldEndEditing:]
#17     0x946f99ee in -[NSTextView(NSSharing) resignFirstResponder]


Andy Balholm
(509) 276-9718
andy@balholm.com



On Jun 23, 2009, at 1:06 AM, Fred Kiefer wrote:

Andy Balholm wrote:
The bindings in my Company Info window are supposed to be read-write,
but they can only read the data from the model. Changes to the text in the fields do not change the model. I tried taking the bindings out of the NIB and binding the fields programmatically instead, and it didn't
make any difference. Once again, it works fine under Cocoa, but not
under GNUstep.


Support for key value binding is still very limited in GNUstep. Most
likely we are just missing a call to our internal method
reverseSetValueFor: here. We are calling this method from [NSControl
sendAction:to:] and this only gets called when you leave the text fields
with the return key. In that case the values seem to get properly
stored. What seems to be missing is a similar call when the field is
changed by any other way.
Does anybody know, when we should send the action for a text field?
Perhaps we have to send that regardless of the way the field gets changed?

Fred






reply via email to

[Prev in Thread] Current Thread [Next in Thread]