Announcement

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

    Button with setCanHover(true); setHoverDelay(0); does not show hover

    Hi Isomorphic,

    I have this Button (v9.1p_2014-05-11, deployed, FF26.0 and Chrome 34.0):
    Code:
    import com.smartgwt.client.widgets.Button;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.events.HoverEvent;
    import com.smartgwt.client.widgets.events.HoverHandler;
    import com.smartgwt.client.widgets.events.MouseOutEvent;
    import com.smartgwt.client.widgets.events.MouseOutHandler;
    
    public class ReloadImgButton extends Button {
    	public ReloadImgButton() {
    		super();
    		setIcon("[SKINIMG]action-icon_28px/refresh-color.png");
    		setBaseStyle("actionButton");
    
    		setWidth(80);
    		setShowFocused(false);
    		setShowDown(false);
    		setCanHover(true);
    		
    		setPrompt("Reload list");
    		setTitle("Refresh");
    [B]		setHoverDelay(1);[/B]
    
    		addHoverHandler(new ReloadImgButtonHoverHandler());
    		addMouseOutHandler(new ReloadImgButtonMouseOutHandler());
    	}
    	
    	private class ReloadImgButtonHoverHandler implements HoverHandler {
    		@Override
    		public void onHover(HoverEvent event) {
    			setIcon("[SKINIMG]action-icon_28px/refresh-white.png");
    		};
    	}
    
    	private class ReloadImgButtonMouseOutHandler implements MouseOutHandler {
    		@Override
    		public void onMouseOut(MouseOutEvent event) {
    			setIcon("[SKINIMG]action-icon_28px/refresh-color.png");			
    		}
    	}
    }
    This works fine. If you set the delay with to 0 with setHoverDelay(0), the hover-effect isn't executed anymore. I can live with a delay of 1, but I think this is a bug.
    As note: In the server logs I see that the hover-image is requested, but it is not displayed.

    Can you reproduce?

    Best regards,
    Blama
    Last edited by Blama; 14 May 2014, 11:54.

    #2
    The problem is that hoverDelay:0 causes the hover to happen synchronously, and then mouseOut fires because of the hover being shown (since the mouse is no longer over the button - it's over the hover), so the effect is undone by your mouseOut handler.

    You can just add logging to your code to see this.

    Comment


      #3
      Hi Isomorphic,

      thanks for the answer. I can't reproduce with my code (no "mousing over [Hover]"), but this makes sense to me.
      I get the following log entries:
      Code:
      16:59:39.660:TMR4:DEBUG:EventHandler:mousing over [HStack ID:isc_SectionHeader_0_controlsLayout]
      16:59:40.621:TMR5:DEBUG:EventHandler:mousing out of [HStack ID:isc_SectionHeader_0_controlsLayout]  mousing over [Button ID:isc_ReloadImgButton_0]
      16:59:55.591:TMR6:DEBUG:EventHandler:mousing out of [Button ID:isc_ReloadImgButton_0]  mousing over [HStack ID:isc_SectionHeader_0_controlsLayout]
      16:59:55.670:TMR7:DEBUG:EventHandler:mousing out of [HStack ID:isc_SectionHeader_0_controlsLayout]  mousing over [Button ID:isc_FilterImgButton_0]
      (I added the buttons to a Section's SectionHeader controls and moved in the section from DevConsole as in the attached picture. In this example, the ReloadButton has the setHoverDelay(0))

      I also noted that if I move from the Filter button (setHoverDelay(1)) directly to the DevConsole, I get no "mousing out" event logged, but the icon changed back to the way it was before. I don't care for this, but it might be a bug in logging?

      I'll open another thread for best practice here.

      Thanks,
      Blama
      Attached Files

      Comment

      Working...
      X