From: Ron W. <rwh...@ar...> - 2006-06-27 20:54:22
|
This is the start of a view module. I have started trying to set up the menus. It displays the menu on the screen but gives me the traces below when I try to select something. When I select an item it highlights in blue but will not let me select any other item and does not call my menuItemSelected function. Any idea about where I am off track. Earlier in the code, get a lot of NSException( NSException: Cannot access bounds movieclip until NSView is inserted into view hierarchy., null ) but they do not seem to have an effect on the action that triggers them. Ron public function init(tableModelIn:TableModel, tableUpdateControllerIn:TableUpdateController, appIn:NSApplication):TableUpdateView { v_tableUpdateController = tableUpdateControllerIn; v_tableModel = tableModelIn; app=appIn; //create and set views //window trace (Flashout.INFO,"create conWindow"); conWindow = (new NSWindow()).initWithContentRectStyleMask(new NSRect(50,50,850,500), NSWindow.NSTitledWindowMask | NSWindow.NSResizableWindowMask | NSWindow.NSClosableWindowMask); trace (Flashout.INFO,"Set title"); conWindow.setTitle("Table Maintenance"); conWindow.setBackgroundColor(NSColor.whiteColor()); //ses the background colour trace (Flashout.INFO,"create conView"); conView = (new NSView()).initWithFrame(new NSRect(0,0,600,200)); conWindow.setContentView(conView); trace (Flashout.INFO,"ready to set up menus"); this.setUpMenus() app.run(); return this; } private function setUpMenus():Void{ // root menu var i:Number; var mainMenu:NSMenu = (new NSMenu()).initWithTitle("Table Update Menu"); this.app.setMainMenu(mainMenu); var self:Object = TableUpdateView; // NSNotificationCenter.defaultCenter().addObserverSelectorNameObject(this.v_tableUpdateController, "notify", null, mainMenu); NSNotificationCenter.defaultCenter().addObserverSelectorNameObject(this, "notify", null, mainMenu); trace("adding"); mainMenu.addItemWithTitleActionKeyEquivalent("Plants", "menuItemSelected"); mainMenu.addItemWithTitleActionKeyEquivalent("Sections", "menuItemSelected"); mainMenu.addItemWithTitleActionKeyEquivalent("Bins", "menuItemSelected"); mainMenu.addItemWithTitleActionKeyEquivalent("Quality", "menuItemSelected"); mainMenu.addItemWithTitleActionKeyEquivalent("Types", "menuItemSelected"); mainMenu.addItemWithTitleActionKeyEquivalent("Variety", "menuItemSelected"); i = mainMenu.itemArray().count(); while (i--){ trace(Flashout.INFO,"Setting target for " + i); mainMenu.itemArray().objectAtIndex(i).setTarget(self); } // app.setMainMenu(mainMenu); } public static function menuItemSelected(cell:NSMenuItemCell):Void{trace(Flashout.INFO,"a menu item was selected");} public static function notify(n:NSNotification):Void{trace(Flashout.INFO,"notify was called with "+ASUtils.extern(n.name));} NSException( NSException: Cannot access bounds movieclip until NSView is inserted into view hierarchy., null ) [19:19:265] debug: org.actionstep.NSMenuView.mouseTrackingCallback() selecting new item... [19:19:265] debug: org.actionstep.NSMenuView.setHighlightedItemIndex() in [19:19:905] debug: org.actionstep.NSEvent.startPeriodicEventsAfterDelayWithPeriod() NSException( NSIllegalOperationException: Periodic events are already being generated. If you would like to change the period, stop periodic events then start., null ) |