Announcement

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

    SelectItem and IconClickHandler - event called on dropdown icon

    I'm using the nightly build of SmartGWTEE from yesterday.

    I wanted to have a SelectItem or ComboItem and an "+" Icon to create a new element. This does not work. It seems that the IconClickHandler is called when you click the SelectItem dropdown arrow as well as the Icon. This seems like a bug to me.

    Adapted from example: http://www.smartclient.com/smartgwt/showcase/#form_details_icons

    Code:
        public void onModuleLoad() {
        	
            final DynamicForm form = new DynamicForm();
            form.setWidth(200);
            
            FormItemIcon icon = new FormItemIcon();
            icon.setSrc("[SKIN]/actions/help.png");
            
            final SelectItem severityLevel = new SelectItem();
            severityLevel.setName("severityLevel");
            severityLevel.setTitle("Severity Level");
            severityLevel.setDefaultValue("Severity 2");
            severityLevel.setIcons(icon);
            severityLevel.addIconClickHandler(new IconClickHandler() {
    			public void onIconClick(IconClickEvent event) {
    				SC.say(HELPTEXT);
    			}
            });
            
            form.setFields(severityLevel);
    
            form.draw();
        }

    #2
    I found a workaround using this example (I just create a button)

    http://www.smartclient.com/smartgwt/...ry_focus_first

    Comment


      #3
      You're adding an IconClick handler to the item as a whole, so you get notification of all clicks on icons, and the picklist drop down icon is considered an icon. If you only want to register for clicks on your added icon, add the click handler there only.

      Comment


        #4
        Ah. That makes sense. Thank you.

        Might I suggest you update the Showcase example to add the handler to the Icon rather than the whole item. While it works with the existing showcase example it easily leads to confusion.

        Comment


          #5
          Good idea, we'll update it.

          Comment

          Working...
          X