Layer blocking events to Menu

20 views
Skip to first unread message

Joseph Marlin

unread,
Oct 3, 2011, 9:45:33 PM10/3/11
to cocos-...@googlegroups.com
This is probably a pretty basic question. I had a menu, menu_b working quite nicely. I added a new layer to the scene containing that Menu Layer. (Menu layer is actually several menus multiplexed). 

Anyway, this layer I added to the scene starts invisible, becomes visible in on_enter() for menu_b, and is set invisible again in the on_exit() for menu_b. Specifically, I am calling: director.scene.children[1][1].visible = True in the menu_b's on_enter(). For some reason, doing this breaks the menu! You can no longer click menu items, and hovering over menu items doesn't change their appearance as it should. 

The menu works fine if I do NOT call 'director.scene.children[1][1].visible = True'. Any ideas why that is messing the menu up?

claudio canepa

unread,
Oct 3, 2011, 10:11:36 PM10/3/11
to cocos-...@googlegroups.com
Doing a grep / find in files for 'visible' don't give hits in code handling events, so I would say is totally unexpected.
Really the only difference in code that triggers the behavior change is commenting out the line
  director.scene.children[1][1].visible = True
?

Sounds more like forgetting to call super in menu_b on_enter

Can you make a small script showing the problem and paste somewhere ?

--
claudio
 

Joseph Marlin

unread,
Oct 3, 2011, 10:17:13 PM10/3/11
to cocos-...@googlegroups.com
Well just to be safe, here is the whole thing: http://dl.dropbox.com/u/1920393/tac.zip

The "connect" menu is the menu with the issue. Hopefully it will behave the same for you as it did for me...

Thanks so much for helping me out with this!

claudio canepa

unread,
Oct 4, 2011, 12:12:18 AM10/4/11
to cocos-...@googlegroups.com
 You have a combination of issues there.
missing 
super(ConnectMenu, self).on_enter()

ConectMenu hay only one item, so it can't change between items, hence no animation (but the mouse will produce action if the mentioned super is added.

Down the road you can have other problems, because you are not calling
super(ConnectMenu, self).on_exit()

Anyway, you are filtering for ip characters. Much more readable and simpler would be to get rid of the ip layer and add to ConnectMenu an EntryMenuItem for the ip, overriding on_text or on_key_press to filter unwanted characters.

--
claudio
   

Joseph Marlin

unread,
Oct 4, 2011, 9:13:48 AM10/4/11
to cocos-...@googlegroups.com
Wow, I wasn't even all that close, was I? Well, sorry for missing something so obvious, and thanks so much! 
Reply all
Reply to author
Forward
0 new messages