Announcement

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

    SKIN location MenuItem vs ToolStripButton

    Hi,
    1) it's very confusing to have a different behavior of the [SKIN] location on a MenuItem then everywhere else.

    Usually, this gives the right URL on most components:
    setIcon("[SKIN]/actions/approve.png");
    but not on MenuItem, this gives a 404. On a ToolStripButton this works.

    This location is OK to show the approve icon on the MenuItem:
    setIcon("[SKIN]/../actions/approve.png");



    2) Setting ToolStripButton.setShowTitle(false) also hides its icon.
    - There is no setShowIcon(boolean) method

    I wanted to set a title and switch on the title in my clickhandler, so I could have just one handler for all ToolStripButtons, since there is no setName(String) on ToolStripButton.




    Repro:
    Code:
    public VLayout getTest1() {
    	VLayout panel = new VLayout();
    	
    	//This icon location is translated into the following URL
    	//404 - GET /smarteetester/sc/skins/Enterprise/images/Menu/actions/approve.png
    	MenuItem validateMenuItem = new MenuItem("Icon is gone");
    	validateMenuItem.setIcon("[SKIN]/actions/approve.png");
    	
    	//This points to the correct location
    	MenuItem validateMenuItem2 = new MenuItem("Icon is OK");
    	validateMenuItem2.setIcon("[SKIN]/../actions/approve.png");
    	//...which is confusing, because on ToolStripButton the 'normal' location must be set:
    	
    	
    	//This is OK
    	ToolStripButton validateButton2 = new ToolStripButton();
    	validateButton2.setIcon("[SKIN]/actions/approve.png");
    	
    	//An icon is desired, but a title is not
    	ToolStripButton validateButton3 = new ToolStripButton("Title");
    	validateButton3.setIcon("[SKIN]/actions/approve.png");
    	
    	
    	//if I give a title and setShowTitle(false), then the icon disappears as well!
    	ToolStripButton validateButton = new ToolStripButton("Approve");
    	validateButton.setShowTitle(false);
    	validateButton.setIcon("[SKIN]/actions/approve.png");
    	//ToolStripButton has no setName()
    	
    	
    	
    	
    	
    	Menu menu2 = new Menu();
    	menu2.setShowShadow(true);  
    	menu2.setShadowDepth(10);
    	menu2.setItems(validateMenuItem, validateMenuItem2);
    	
    	IMenuButton menuButtonBI = new IMenuButton("Item", menu2);  
    	menuButtonBI.setWidth(100);
    	
    	ToolStrip toolstrip = new ToolStrip();
    	toolstrip.setWidth100();
    	toolstrip.addButton(validateButton);
    	toolstrip.addButton(validateButton2);
    	toolstrip.addButton(validateButton3);
    	toolstrip.addMember(menuButtonBI);
    	
    	
    	panel.addMember(toolstrip);
    	return panel;
    }

    SmartGWT EE 2.3
    GWT 2.0.4
    IE8 dev mode

    #2
    1. It's not just MenuItem, many widgets have a skinImgDir set, which changes the location of [SKIN]. There is a separate [SKINIMG] prefix you can use that always points to the top level "images/" directory, if that's more convenient for a given setting.

    2. It's not clear what appearance you want here, but consider setting title to the null string.

    Comment


      #3
      1: Oh, thanks for that pointer to [SKINIMG], that works.

      2: I want to have just 1 clickhandler which I add to a bunch of ToolStripButtons. In there, I wanted to do event.getSource.getName, but since ToolStripButton doesn't have a 'name', I thought to use 'title' and just hide the title on the ToolStripButtons.

      Comment


        #4
        What's the purpose of event.getSource().getName()? If you have need of a special attribute for your buttons, why not subclass and add your own getter/setter?

        Comment

        Working...
        X