Lefora Free Forum
login join
Loading
897 views

Changing the Propagation of Text in a TextField

Page 1
1–10
novice - member
12 posts

Here is my situation.  In my application, I have a window that prompts for text information that is used and the text field is propagated to other windows.  Initially, this works as designed.  However, when I go back to change that text field, the original text still shows up in the other called windows.  The only time that this works is when the application first gets called.  While in the application, it does not.  How do I get this text data to get re-propagated with the changed text information?  

?
288 posts

You'll need to put the code in place to do that.  It sounds as though you have that solved.  Remember that textFields have no knowledge of each other.  If you copy the string from one to another during startup, you'll have to re-execute that code when necessary.

The subscriber/observer model in Cocoa is provided to call you when a 'watched' value is changed.  Then it's your responsibility to manage the UI implications of the change and you might find that very useful.

However, I strongly suspect that you have the necessary code already done.  You may need to refactor to propogate from from multiple locations.  However, it's probably only a few minutes work.

Good Luck.

__________________
novice - member
12 posts

I will have to take a look at that subscriber/observer model you referenced.  The way I do it initially is to call AwakeFromNIB and when i open the subsequent window(s), it works the first time only.  I'll look at that and see what I need to do to make this work.  Thanks for the tip.

?
288 posts


Well, you've understood it.  awakeFromNib is called once and you propogate, right?  Well, you'll have to refactor your propogation code to a neutral place which you can call from awakeFromNib and when any of the textFields are changed.

It's not necessary to use the observer/subscriber model to implement this - although I think you'll find it very useful for this purpose.  I highly recommend that you get a copy of Aaron Hillegass' book.  He explains the observer/subscriber model and many other features of Cocoa.

__________________
novice - member
12 posts


Yes, I use the awakeFromNib and propagate that way. It's the subsequent back and forth while the app is running that awakeFromNib doesn't change it.
Great minds think alike.  I have Aaron's book and that was the FIRST place I went to after your initial response. I have found answers to many of my questions there, but couldn't quite grasp how to resolve this at first. Because this is a part time effort that I've been embarking on, I don't get alot of time to spend on my application as I like. 

At this point, I'm taking your comments, the observer/subscriber model that is reflected in Aaron's book and piecing it all together.

I'll keep you posted.

As an aside, I wrote Aaron an email when I first bought the book and complimented him on how useful a tool this is over what Apple provides online. I mentioned that my app also calls for using SQLite3 for my database repository and he, without me requesting, gave me some great sample code on how to implement that portion of my application, if I ever get this simple thing fixed.

?
288 posts

I have good news for you.  I was able to get this to work perfectly using bindings.  I have several dialog boxes open as I type into one, the 'watched' strings are all changing.  Works beautifully.  Bindings are some kind of observer/subscriber magic.

I added the sharedDataObject and gave it the name appMagicString.  Then I bound all the NSTextField objects to the labels and dialog boxes.  There's a non-default setting 'update continuously' (or something like that) and then it was working.

I can provide a zip of the project if you wish (I'll drop a zip on clanmills.com and you can pick it up from there, if you wish).

__________________
novice - member
12 posts

Wow!  What unbelievable Karma!!!  I was reading about the Bindings in Aaron's book last night and thought that would simplify the whole process but was way too tired to think it out last night!  Man, we must be on some eerie wavelength!!  I saw that "update continuously" last night when I was looking at my code.  Wasn't sure EXACTLY how it worked, but seems you've zeroed in on that!!!

Yes, please, post it there and I will download it when I get home from work tonight!!!  Thanks and I will let you know how I make out.

?
288 posts

http://clanmills.com/files/WeeTest.zip

Please see "ReadMe.txt" in the archive.

If you'd like to discuss this, let's talk off line - you'll find my email and Skype id in the archive.

I'll report a summary of our off-line discussion back to this forum and post the final version of our code for others to use/abuse/ignore/enjoy or whatever.

__________________
novice - member
12 posts


Hey Robin,

It was just a matter of time and  some "reverse engineering".  

I began with the pseudoname... You used 'appMagicString'... I tried to keep things consistant with the application, "PMBOKSelectorString".

For what I call the "follower" windows, I set the following parameters in the bindings inspector:

  • Always editing multiple selections
  • Conditionally sets editable
  • Continuously updates value
  • Raises for not applicable keys. (nor sure quite what this means yet)

For the PMBOK Selector window that has the ComboBox to allow selecting the correct text, here are the parameters I set in the bindings inspector:

  • Always editing multiple selections
  • Conditionally sets editable
  • Raises for not applicable keys.

In essence, I unchecked the "Continuously updates value" option.  The ComboBox began functioning as designed, and the propagation to the other windows worked, as designed.

Your assistance and vast knowledge of how Interface Builder works made me see that even with the extensive programming years I have, I have much to learn about writing applications for Mac.  Thanks again.

novice - member
12 posts

Robin,

From a former Software Engineer-turned Project Manager to another Software Engineer,  I am elated to have the privilege of being able to receive your technical assistance as I grow and learn to develop applications for my Mac.  

This being the first personal project I’ve undertaken, it has been a struggle just understanding the concepts.  Your knowledge of the infrastructure that allows programming a Mac simple, has been a tremendous asset in my growth. Your directions in these “first steps” have proven to be very valuable.

I look forward to growing in knowledge and skills as I add another resource to my toolbox: You. Rest assured, I may lean on you again as I expand that skill and work towards completing my first Mac program project.

My heartfelt thanks.

Jack

Page 1
1–10

Locked Topic


You must be a member to post in this forum

Join Now!