PDA

View Full Version : nstextview bindings




MrFusion
Aug 14, 2006, 12:20 PM
I have a NSTextView that is binded with coredata. When text is entered, it is not always passed on to the backend when the user does something else. This results in the loss of the data entered. Is there someway to force the nstextview to save the data every time it's changed by the user, without having to resort to delegate methods and manually updating the nsmanagedobject? That would nullify the idea behind bindings, or not.



slooksterPSV
Aug 15, 2006, 01:48 AM
I have a NSTextView that is binded with coredata. When text is entered, it is not always passed on to the backend when the user does something else. This results in the loss of the data entered. Is there someway to force the nstextview to save the data every time it's changed by the user, without having to resort to delegate methods and manually updating the nsmanagedobject? That would nullify the idea behind bindings, or not.
Personally, it sounds like you don't have it binded correctly then. Cause any data you add or remove should stay there. That's just my thought on it...

EDIT: You just helped me out with my app, thanks, here's a screenshot of it:

MrFusion
Aug 15, 2006, 09:02 AM
Personally, it sounds like you don't have it binded correctly then. Cause any data you add or remove should stay there. That's just my thought on it...

EDIT: You just helped me out with my app, thanks, here's a screenshot of it:
You're welcome. :)

caveman_uk
Aug 15, 2006, 10:02 AM
Is it only saving the data when you tab away from the text view? If so, you need to check the 'continuously updates value' checkbox.

slooksterPSV
Aug 15, 2006, 10:07 AM
Is it only saving the data when you tab away from the text view? If so, you need to check the 'continuously updates value' checkbox.
Actually, that just duplicates the value's in the textview - at least it did for me. - What's its type? Is it Binary Data? It has to be Binary Data for it to work.

Other q?s = is it Document-based? Is it based on a selection for the text? e.g. a table selection.

caveman_uk
Aug 15, 2006, 10:13 AM
My textviews were bound to objects in a dictionary (so not core data) and checking that box made sure the users edits were saved (otherwise the edits are not recorded unless the user moves the focus to another control)

slooksterPSV
Aug 15, 2006, 10:48 AM
My textviews were bound to objects in a dictionary (so not core data) and checking that box made sure the users edits were saved (otherwise the edits are not recorded unless the user moves the focus to another control)
See that's how mine works.

That has me think of another question - what are the actions to produce the result:
e.g. User types in box, user clicks on a different application, user changes a property in an NSSheet, user goes back to data and data is gone.

Give us the exact steps, that'll help us out.

MrFusion
Aug 16, 2006, 05:50 AM
See that's how mine works.

That has me think of another question - what are the actions to produce the result:
e.g. User types in box, user clicks on a different application, user changes a property in an NSSheet, user goes back to data and data is gone.

Give us the exact steps, that'll help us out.

I found a fix for it. But this is what happend:
I have two views, with a button to switch between them. This is done with addsubview and removefromsuperview.

The textview was in one of the views. When the user types in text and then clicks on the switch button (the focus is still on the textview) the typed in text is lost. When the user first clicks somewhere else, the text is saved.

I solved it by adding these lines before I switch from the view with the textview to the view without it.

[[myArrayController selection] setvalue:[[[myTextview stringvalue] copy] autorelease] forkey:@"theText"];

Without the copy the text doesn't get retained, and without the autorelease it leaks.

Yes, the bindings are fine, and the 'cont. update' is also checked.

Thanks for the replies.