Announcement

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

    TileGrid Component Hover

    Has anyone managed to get the hoverComponent to work with a TileGrid? I've made use of the following:

    Code:
    @Override
    public Canvas getHoverComponent() {
        Record record = tileGrid.getSelectedRecord();
        DetailViewer hoverViewer = new DetailViewer();
        hoverViewer.setWidth(200);  
        hoverViewer.setDataSource(ds);  
        Criteria criteria = new Criteria();  
        criteria.addCriteria("itemID", record.getAttribute("itemID"));
        hoverViewer.fetchData(criteria);  
        return hoverViewer;
    }
            testCanvas.setShowHover(true);
            testCanvas.setCanHover(true);
            testCanvas.setShowHoverComponents(true);
    When the method is overridden for a normal Canvas object (such as a DynamicForm, for example), the Hover item appears correctly (and bravo - it looks fantastic).
    Overriding the Parent tileGrid does nothing, BUT - this suggests the way forward:
    Originally posted by Isomorphic View Post
    Use setTileProperties() to enable the normal Canvas-level properties and event handlers for hovers.
    The code I've tried to use is as follows:

    Code:
    //TileGrid
        final static TileGrid tileGrid = new TileGrid();
    //setTileProperties Canvas
        final static Canvas tileCanvas = new Canvas(){
        //Override the getHoverComponent for the setTilesProperties Canvas
        //This is identical to the previous test case
            @Override
            public Canvas getHoverComponent() {
                Record record = tileGrid.getSelectedRecord();
                DetailViewer hoverViewer = new DetailViewer();
                hoverViewer.setWidth(200);  
                hoverViewer.setDataSource(ds);  
                Criteria criteria = new Criteria();  
                criteria.addCriteria("itemID", record.getAttribute("itemID"));  
                hoverViewer.fetchData(criteria);  
                return hoverViewer;
            }
        };
        final static DataSource ds = SwitchXmlDS.getInstance();
        private static void setupTileGrid() {
            tileCanvas.setShowHover(true);
            tileCanvas.setCanHover(true);
            tileCanvas.setShowHoverComponents(true);
            //set the TileProperty to use tileCanvas settings
            tileGrid.setTileProperties(tileCanvas);
            }
    Unfortunately this doesn't trigger a DetailViewer hovercomponent. There's a dearth of use cases, and javadoc the isn't enlightening.

    Thanks,

    Terry

    #2
    Additional information

    I should have included (I thought I had :-( ) the following - SmartClient Version: v9.1p_2014-07-15/LGPL Development Only (built 2014-07-15)

    Before I go and put together a minimal testcase - could someone tell me if this functionality is supported (ComponentHover over Tile).

    Thanks,

    Terry

    Comment


      #3
      Tiles can in general do anything, but you should look at the Custom Tiles example in the Showcase to see how to provide your own tile class. Using properties to install event handlers usually works but you can class with built-in behaviors. A complete custom tile class avoids this.

      Comment


        #4
        Thanks for the pointer but unfortunately I haven't been able to get this to work. My custom tile class is as follows:

        Code:
        public class SwitchTile extends DynamicForm {  
            final static DataSource ds = SwitchXmlDS.getInstance();
            public SwitchTile() {
               StaticTextItem itemA = new StaticTextItem("model");  
                itemA.setShowTitle(false);  
                StaticTextItem itemB = new StaticTextItem("accessports");  
                itemB.setShowTitle(false);  
                setFields( itemA, itemB); 
                setCanHover(true);
                setShowHover(true);
                setShowHoverComponents(true);
            }
            getHoverComponent Option
            @Override
            public Canvas getHoverComponent() {
                final Record record = getValuesAsRecord();
                DetailViewer hoverViewer = new DetailViewer();
                hoverViewer.setDataSource(ds);
                hoverViewer.setWidth(200);  
                Criteria criteria = new Criteria();  
                criteria.addCriteria("model", record.getAttribute("model")); 
                hoverViewer.fetchData(criteria);
                return hoverViewer;
            }
        }
        The dynamic form is being used to populated the TileGrid, but the Hover event is not triggered. I've seen something similar with a normal DynamicForm (not tiled), where the form children (e.g. a selectitem or textitem) intercepts the hover activity.

        Thanks,

        Terry

        Comment


          #5
          It looks like you're now using a DynamicForm - DynamicForm has a more specialized FormItem-centric hover subsystem (ItemHover, ValueHover etc events) that supersedes the Canvas-level hover subsystem.

          Unfortunately it doesn't provide the handy concept of a hoverComponent, so you'd have to manage that part on your own. Or avoid using a DynamicForm - it doesn't look like you need much more than two side-by-side bits of text, at least in your current code.

          Comment


            #6
            Would you recommend extending a SimpleTile? Here's my attempt with that, but once again, no Hover is generated.

            Code:
            public class SwitchTile extends SimpleTile {
            	{
            	        setShowHover(true);
            	        setCanHover(true);
            	        setShowHoverComponents(true);
            	}
            	final static DataSource ds = SwitchXmlDS.getInstance();
            	@Override
            	public DetailViewer getHoverComponent () {  
            		DetailViewer hoverViewer = new DetailViewer();
            		hoverViewer.setWidth(200);  
            		hoverViewer.setDataSource(ds);  
            		Criteria criteria = new Criteria();  
            		criteria.addCriteria("model", getRecord().getAttribute("model"));  
            		hoverViewer.fetchData(criteria);  
            		return hoverViewer;
            	}
            }
            Thanks,

            Terry

            Comment


              #7
              We've made a change to TileGrid which should get your most recent sample working - please try the next nightly, dated Aug 9 or above

              Regards
              Isomorphic Software

              Comment

              Working...
              X