• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Trying to bind an array to a table in an NSView...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Trying to bind an array to a table in an NSView...


  • Subject: Trying to bind an array to a table in an NSView...
  • From: Jeff Dyck <email@hidden>
  • Date: Tue, 15 Mar 2011 16:27:50 -0700

Hello all...

I'm hoping someone can give my brain a kick and help see what I'm doing wrong...

I'm working on updating an in house application to both expand functionality and migrate to ASOC... 
Because of the increased options I'm trying to put into the program, I'm revisiting the UI. 

So far I'm just trying to get the UI updates working in a separate test project before I integrate it into the bigger project.  I thought I had it working (the UI switching works and looks lovely), but that seems to break my table bindings...

What I'm trying to do:
My application is basically a user facing admin console for a database backend.  There are several different types of 'data' that can be edited, and I want to change the view depending on what data the user is working on.  I based my initial code on the ideas presented in Chapter 12 of Shane's book - Swapping Views, with a few changes:

• I programatically resize the NSViews to fit the window space available, rather than the other way around.
• I start with a blank main window and load in the main UI - seemed to make the switching back and forth easier.
• I'm animating the change

Details:
• I have a blank main window - it's Content view is bound to the mainUIFrame property in my script.
• I have the MainUI view, bound to mainUIView, which is immediately loaded into the main window.
• The MainUIView also has a table, which is bound via an NSArray to the testArray property in the main script.

If I have the table directly on the Main window, this works, but as soon as I put it onto an NSView and load that into place, it doesn't work. Further, if I load secondary array, THEN set my testArray to the second array, it also works.  

ie: for the loop to create test data, if I do the following it works, but seems silly to be creating a ton of extra arrays:
set dummyList to {}


set x to 1
repeat while x < 50
set end of dummyList to {lCode:"Code" & x, lName:"Name" & x, lLocation:"Location" & x}
set x to x + 1
end repeat


set my testArray to dummyList

I even tried binding the table to the script so I could send it a reloadData() command, but that didn't work either.

Anyway, here is my simplified script:

property parent : class "NSObject"


property currentView : missing value -- I use this to keep track of which is the current view, for the replaceSubview:with: command
property mainUIFrame : missing value -- This is bound to the Content view of the Main window
property mainUIView : missing value -- This is bound to a custom NSView, which contains the main UI
property siteEditView : missing value -- This is bound to a second custom NSView, which contains a UI for editing Site data
property testArray : {} -- Test Array is bound to an NS Array controller, which is bound to a table.


on applicationWillFinishLaunching_(aNotification)
--Apparently I need to do this to get animation working...
mainUIFrame's setWantsLayer_(true)


--Load the main UI
changeMainView_(mainUIView)

--Create some simple data to test with

set x to 1
repeat while x < 50
set end of my testArray to {lCode:"Code" & x, lName:"Name" & x, lLocation:"Location" & x}
set x to x + 1
end repeat

end applicationWillFinishLaunching_


on changeMainView_(desiredView)
set currentSize to mainUIFrame's frame()
desiredView's setFrame_(currentSize)


--If this is the first time, the currentView will be null and I need to use addSubview instead of replaceSubview

if currentView is missing value then
mainUIFrame's addSubview_(desiredView)
else
mainUIFrame's animator's replaceSubview_with_(currentView, desiredView)
end if

--Update currentView for when I want to switch back
set currentView to desiredView
end changeMainView_


--These two functions are triggered by UI to switch views

on enterSiteEditor_(sender)
changeMainView_(siteEditView)
end enterSiteEditor_


on finishSiteEditing_(sender)
changeMainView_(mainUIView)
end finishSiteEditing_



Jeff Dyck | Analyste de reseaux - Mac OS X
Conseil Scolaire Francophone de la Colombie-Britannique (SD 93)
3550 Wellington Street, Annexe B - Port Coquitlam, BC - V3B 3Y5
Tel: 778-284-0902 - Cell: 778-990-7960 - http://support.csf.bc.ca

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Trying to bind an array to a table in an NSView...
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: xCode 4.0
  • Next by Date: Re: Trying to bind an array to a table in an NSView...
  • Previous by thread: Re: App response issue
  • Next by thread: Re: Trying to bind an array to a table in an NSView...
  • Index(es):
    • Date
    • Thread