On Wed, Aug 8, 2012 at 8:58 PM, Roger L. Whitcomb
<[email protected]> wrote:
> Okay, I just compiled and tested this simple example and it worked (in so
> far as the TreeView was instantiated correctly and my custom skin was
> installed).
>
> Does your custom skin have a no-arg constructor?  That's the only reason I
> can see that the "InstantiationException" would be thrown.
>
> HTH,
> ~Roger
>
> import org.apache.pivot.wtk.*;
> import org.apache.pivot.collections.*;
> import org.apache.pivot.wtk.skin.terra.*;
>
>
> public class Test extends Application.Adapter
> {
>         public static class MyTreeSkin extends TerraTreeViewSkin
>         {
>                 public MyTreeSkin() {
> System.out.println("MyTreeSkin()");
>                 }
>                 @Override
>
>
>                 public boolean mouseClick(Component component, Mouse.Button
> button, int x, int y, int count) {
>                         return super.mouseClick(component, button, x, y,
> count);
>                 }
>         }
>
>         @Override
>         public void startup(Display display, Map<String,String> properties)
> {
>                 Theme.getTheme().set(TreeView.class, MyTreeSkin.class);
>                 new TreeView();
>         }
>
>         public static void main(String[] args) {
>                 DesktopApplicationContext.main(Test.class, args);
>
>         }
> }
>
>
>
> -----Original Message-----
> From: Josh R [mailto:[email protected]]
> Sent: Wed 8/8/2012 5:27 PM
> To: [email protected]
> Subject: Re: How to block UI input to a disabled/busy TreeNode
>
> On Wed, Aug 8, 2012 at 8:12 PM, Roger L. Whitcomb
> <[email protected]> wrote:
>> Okay, I think the thing to do is this:
>>
>> myApp.startup(...) {
>> ...
>>         Theme.getTheme().set(TreeView.class, MyTreeSkin.class);
>> ...
>>
>> Then you don't need a MyTreeview class at all, and when you instantiate a
>> TreeView it will automatically get the MyTreeSkin as its skin....
>>
>> See if that works.
>
> Nope.
>
>
> java.lang.IllegalArgumentException: java.lang.InstantiationException:
> com.foobar.proto.main_proto$MyTreeSkin
>         at org.apache.pivot.wtk.Component.installSkin(Component.java:834)
>         at org.apache.pivot.wtk.TreeView.<init>(TreeView.java:924)
>         at org.apache.pivot.wtk.TreeView.<init>(TreeView.java:908)
>         at
> com.foobar.proto.main_proto.create_hosts_tree(main_proto.java:665)
>         at com.foobar.proto.main_proto.startup(main_proto.java:837)
>
>
>>


Thanks Roger. I was out so I couldn't try the code earlier. I was able
to extend the custom skin. There was some problem with eclipse(figured
that when your code wasn't working in my IDE). I had to right-click on
the project and choose, Run-As to get it going again...

So getting back to the question - blocking UI input to a TreeNode:

Now this is what I do in my extended MyTreeSkin::mouseClick function:

mouseClick(component, mouse ...) {
boolean consumed=true;
// get the node from the Tree...
// read the node's state...
if (my_node.disable_node)
   return consumed;
else
   return super.mouseClick();
}

Now, MyTreeView has a right-contextMenu setup via the setMenuHandler.
So when I return 'consumed' from mouseClick above (which would imply
the click was consumed), I was expecting the contextMenu to not get
called. However, my contextMenu() is still getting called for this
node.

Do we need to add anything else too to block the event propagation?

thanks

Reply via email to