Register for Notifications

Coding Questions, IDE related or anything else

Register for Notifications

Postby udo.killermann » Thu Apr 08, 2010 8:12 pm

Hello OB-Forum,

I am experimenting with NSComboBox right now. Looking at the class reference I see notifications for the combobox which are sent when certain conditions change (e.g. NSComboBoxSelectionDidChangeNotification). How can I register to receive notifications in my OB Code? I tried to capture it using Event keyword but did not suceed. Did I miss something?

Thanks for your answer
Udo
--------------
MacBook (2GHz, 4 GByte) - Lion (10.7.3)
started Objective Basic coding in April 2010 - still enjoy it ;-)
udo.killermann
 
Posts: 247
Joined: Thu Apr 08, 2010 6:46 am
Location: Hannover, Germany

Re: Register for Notifications

Postby berndnoetscher » Fri Apr 09, 2010 9:43 am

Well, I assume you just want to react to the user changes of the selected item in the NSComboBox. This is how it works.

You need to declare an IBAction in code.

Code: Select all
IBAction cbselected(sender As id)
  Alert(myCombobox.SelectedObject())  ' myCombobox is set as IBOutlet somewhere in code here
End IBAction


And then go to Interface Builder and connect the NSComboBox to the IBAction.

Whenever you change the selected item an alert will appear showing the selected item as text.

By the way, the keyword Event is used to override existing class implementations.
berndnoetscher
Site Admin
 
Posts: 280
Joined: Fri Feb 20, 2009 11:58 am

Re: Register for Notifications

Postby udo.killermann » Fri Apr 09, 2010 6:56 pm

Thanks for your answer. It took me a while to understand the concept of wiring UI elements within IB to actions and outlets. Why the name of the notification isn't even referenced within IB was counterintuitiv to me.

Thanks for hinting me to the event concept to override class methods.

BTW: I started coding in Basic on an Apple ][+ in the late 70s. I am happy to see that a modern implementation is back on my Apple (this time MacBook).
--------------
MacBook (2GHz, 4 GByte) - Lion (10.7.3)
started Objective Basic coding in April 2010 - still enjoy it ;-)
udo.killermann
 
Posts: 247
Joined: Thu Apr 08, 2010 6:46 am
Location: Hannover, Germany


Return to Objective-Basic (Xcode 3)

Who is online

Users browsing this forum: No registered users and 1 guest

cron