Announcement

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

    PickerIcon setName and getName

    Dear all,

    I am trying to get pre-set pickericon name through onBrowserEvent listener but with no luck. I have created pickericon and add it to the textitem which is then added to the form item and window.
    If i look at the browser HTML source i can see that name is set as $9a="pickericon" and not as name as expected. Also name is set to underlying span item not on img item, so i have to operate with getParent.....

    Code is as follows:
    Code:
    DynamicForm form = new DynamicForm();
    
    PickerIcon pi = new PickerIcon(PickerIcon.SEARCH);
    pi.setName("pickericon");
    pi.addFormItemClickHandler(new FormItemClickHandler() {
    @Override
    public void onFormItemClick(FormItemIconClickEvent event) {
    System.out.println("icon click");
    }
    });
    
    TextItem ti = new TextItem();
    ti.setIcons(pi);
    
    form.setItems(ti);
    
    Window window = new Window();
    window.setWidth(600);
    window.setHeight(200);
    window.setAutoCenter(true);
    window.setIsModal(true);
    window.addItem(form);
    window.show();
    
    Event.sinkEvents(window.getElement(), Event.ONMOUSEDOWN);
    Event.setEventListener(window.getElement(), new EventListener() {
    @Override
    public void onBrowserEvent(Event event) {
    if (Event.ONMOUSEDOWN == event.getTypeInt()) {
    
    // how to get icon name and not auto-generated id on click ???
    
    }
    }
    });


    #2
    By design, the DOM rendered by SmartGWT is undocumented, because we need to change it periodically to handle different browser bugs and/or to get the best possible performance.

    What are you trying to do? If you believe it's impossible to do what you're doing without direct access to the DOM, please explain why.

    Comment


      #3
      I have two events. One is when the user has left the text input (blur) and the other when user clicks on the icon beside text input. If focus is inside text input and user clicks on the icon, i want to block blur event on the text input. I can only think of window event onmousedown, which is fired before text blur and icon click.
      So, i would like to cancel function in the blur event if someone clicks on the icon.

      I don't need this function to be browser compatible because "standard" browser for this app is G-Chrome.

      Comment


        #4
        Is it possible to get/set icon name or not? setAttribute is not working as expected ...

        Comment


          #5
          you have to explain what you're trying to do, from the user perspective.

          Comment


            #6
            Hi mrpiagg,

            *Perhaps* in your blur-event handler you can use the static com.smartgwt.client.util.EventHandler.getTarget() in an if and see that your icon was clicked.
            I did not try this, though.

            Best regards
            Blama

            Comment


              #7
              Blama,

              thanks for your suggestion. com.smartgwt.client.util.EventHandler.getTarget() returns dynamicform and not icon item :(


              Right now I have found out, that i was using wrong combination of icons and text field (TextItem, DateItem, etc). I had problems with DateItem which fired blur event first and than icon click. I was using DateItem in combination with setShowPickerIcon(true) which fires blur event before click.

              Working code for blur to happen only when i go to the next field and not on icon click is like this:

              Code:
                      final DateItem di = new DateItem("date", "date");
                      
                      PickerIcon pid = new PickerIcon(PickerIcon.DATE);
                      pid.addFormItemClickHandler(new FormItemClickHandler() {            
                          @Override
                          public void onFormItemClick(FormItemIconClickEvent event) {
                              di.showPicker();                
                              System.out.println("pid click");            
                          }
                      });    
                      
                      di.setUseTextField(true);
                      di.setShowPickerIcon(false);
                      di.setIcons(pid);
                      di.addBlurHandler(new BlurHandler() {            
                          @Override
                          public void onBlur(BlurEvent event) {
                              System.out.println("bh date");
                              // custom blur function
                          }
                      });

              Comment

              Working...
              X