StackLayoutPanel change default behaveeior for header onclick

157 views
Skip to first unread message

Mark Wengranowski

unread,
Jul 27, 2012, 12:13:43 PM7/27/12
to google-we...@googlegroups.com
Hi Everyone,

I want my stacklayoutpanel to only change stacks when i click on a button i've created and not when someone clicks on the header. i.e. i only want the stack to change once my validation has passed.

The only way I can see to do this is to copy/paste the StackLayoutPanel.java code into my own file and remove the handler that gets added to the header. Then use my custom SLP for my ui.

Does anyone have a better alternative? I'm unable to override the insert method for stacklayoutpanel

Rob Whiteside

unread,
Jul 27, 2012, 4:14:22 PM7/27/12
to google-we...@googlegroups.com
Looks like you can register a "BeforeSelectionHandler" then just call cancel on the event.  Looks like that's what it's intended for.

--Rob

Mark Wengranowski

unread,
Jul 27, 2012, 5:06:34 PM7/27/12
to google-we...@googlegroups.com
OK, if i do that i can call event.cancel() wich stops it from changing.

My button that changes the stackpanel to the next stack uses the showWidget(int) method and when i call that it triggers the same event which is then cancelled. Is there a work around for this? I guess i could just put in a switch or something that would detect if it was a header click vs a button click?

Rob Whiteside

unread,
Jul 27, 2012, 5:12:05 PM7/27/12
to google-we...@googlegroups.com
Yup, Probably gotta add a switch.  Or do your validation in your beforeSelectionHandler rather than on the button click, then you'd remove the button all together.  (Unless of course your button has other purposes)

Good luck,
--Rob

Mark Wengranowski

unread,
Jul 27, 2012, 5:14:00 PM7/27/12
to google-we...@googlegroups.com
Thanks for your help Rob!

Cheers,
-Mark
Reply all
Reply to author
Forward
0 new messages