Announcement

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

    Icon Position

    Hello SGWT Team,
    I 'm looking for to get position of FormItem, the situation is that I have a left navigation side window which can be collapsed and different FormItems in the midle side, so I want to catch the position (relative/absolute) in pixel, in the aim to show a little menu, on the left.
    some code
    Code:
    FormItemIcon icon;
    ...
    
    
     public void onFormItemClick(FormItemIconClickEvent event) {
    
    //How to get the right position of icon
    menu = new Menu();
    
    //AIM to move the menu on the right position
    menu.setPageLeft(left);
    menu.setPageTop(top);
    menu.show();
    
    
    }
    is there any way to do this?
    thanks in adavnce

    #2
    There is no way to get the position as they are not a Canvas. You can add a click handler to the parent Canvas though. Then inside the FormItemIcon click handler simply set sometype of flag, check for the flag in the parent click handler, if it is set then show the menu using the event.getX(), event.getY()

    Comment


      #3
      Thx,
      The event have not the detX(), so I just copy the getX() of SmartGWT of other events and go right

      Code:
      /**
           * Return the page-relative X (horizontal) coordinate of an event.
           *
           * @return x-coordinate in page coordinate space
           */
          public static native int getX() /*-{
              return $wnd.isc.EventHandler.getX();
          }-*/;
      thx

      Comment


        #4
        Actually easier way, if you have a click handler on your form item, inside the click handler call EventHandler.getX() and EvenHandler.getY(), it will let you pop up something where the click happened then. Though basically what you have, but you don't need to define that function it is already available.
        Last edited by svjard; 22 Jun 2010, 08:27.

        Comment

        Working...
        X