Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    CanvasItem with Button

    Code:
    public void onModuleLoad() {
    		SC.showConsole();
    
    		VLayout layout = new VLayout();
    
    		Button b = new Button("b");
    		b.addClickHandler(new ClickHandler() {
    			public void onClick(ClickEvent event) {
    				System.out.println("clicked");
    			}
    		});
    				
    		CanvasItem ci = new CanvasItem();
    		ci.setCanvas(b);
    				
    		DynamicForm form = new DynamicForm();
    		form.setItems(ci);
    
    		layout.addMember(form);
    		layout.draw();
    	}
    With the smartGWT night build and GWT 2.3, the onClick() method is never called. Nothing unusual appears in console.
    Im aware of the ButtonItem component, but I use the same Button type in several part of the application, even outside forms.
    I suspect its some bug introduced lately.
    Any idea of how keep to use the Button instead ButtonItem? Thx.
    Last edited by bebo; 25 Jul 2011, 05:53.

    #2
    What's the fully qualified class name of "Button"? If it's not a SmartGWT widget, see the FAQ about mixing widgets.

    Comment


      #3
      It's a com.smartgwt.client.widgets.Button
      The code was working as expected with less recent night builds. Unfortunately I've been stupid and I overwrite the previous jars, so I can't tell which one it was.

      Comment


        #4
        No Problem - we know what this is. We've made a fix which will be present in upcoming nightly builds (including the 2.5 final release)

        Comment


          #5
          Cool, thanks

          Comment


            #6
            I have the same problem and have checked the sample code from bebo from above with the Smart GWT 2.5 release; the button class is
            Code:
            com.smartgwt.client.widgets.Button
            Still, the onClick is not sent at all, same for ImgButton, both for compiled and debug mode.

            Is there any workaround or fix for this?

            Comment


              #7
              This problem cannot be reproduced with this test case in 2.5. Perhaps you are seeing an unrelated problem.

              Comment


                #8
                This code demonstrates the problem:
                Code:
                public class GwtDemo implements EntryPoint {
                
                    public void onModuleLoad() {
                        System.out.println("SmartGWT-Version: " + Version.getVersion() + " GWT version: " + GWT.getVersion());
                        IButton button = new IButton("Hello World");
                        button.setIcon("http://www.smartclient.com/smartgwt/showcase/images/pieces/16/cube_green.png");
                        button.addClickHandler(new ClickHandler() {
                            public void onClick(ClickEvent event) {
                                System.out.println("single click");
                            }
                        });
                        button.addDoubleClickHandler(new DoubleClickHandler() {
                            @Override
                            public void onDoubleClick(DoubleClickEvent event) {
                                System.out.println("double click");
                            }
                        });
                        button.addIconClickHandler(new IconClickHandler() {
                            @Override
                            public void onIconClick(IconClickEvent event) {
                                System.out.println("icon click");
                            }
                        });
                                        
                        CanvasItem ci = new CanvasItem();
                        ci.setShowTitle(false);
                        /*
                        ci.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
                            @Override
                            public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
                                System.out.println("canvasItem click");
                            }
                        });
                        */
                        ci.setCanvas(button);
                
                        DynamicForm form = new DynamicForm();
                        form.setItems(ci);
                        
                        VLayout layout = new VLayout();
                        layout.addMember(form);     
                        layout.draw();
                    }
                }
                The sysout at the beginning shows on my system
                Code:
                SmartGWT-Version: 2.5 GWT version: 2.3.0
                In the example, events on the button are received for icon click and for double click, but never for single click.
                Still, when I uncomment the click handler on the canvas item, it sends the canvasItem click event, only the button click handler is never called.
                Seems for me like there is a new precedence since 2.5 which only sends the event to the canvas item click handler if the button is wrapped in a canvas item. If the button is not wrapped instead, the button receives the single click event.

                In the previous smartGWT version, the single click on the button was sent even when it was wrapped.
                No problem, though, I can change my calls.

                Comment


                  #9
                  This is odd - this should be fixed and we are not reproducing this with your exact code, against the 2.5 release. In our test, using your code, completely unchanged, the 'click', 'doubleClick' and 'iconClick' events all log to the Console as expected.

                  To verify the version info, can you open the SmartGWT developer console [SC.showConsole() - note that you may need to allow pop-ups] and evaluate "isc.version" and let us know the result.

                  In addition to this - what browser / OS are you encountering this on?

                  Comment


                    #10
                    Found the problem: Wrong SmartGWT library. My version was
                    SC_SNAPSHOT-2011-07-23/LGPL Development Only (built 2011-07-23)
                    while the final release is a week younger
                    SC_SNAPSHOT-2011-08-02/LGPL Development Only (built 2011-08-02)

                    Thanks for leading me the right way

                    Comment

                    Working...
                    X