4

adding a menuitem with image on Menubar

asked 2013-03-14 12:21:18 +0800

nsharma gravatar image nsharma flag of India
917 1 11

updated 2013-03-15 02:34:23 +0800

vincentjian gravatar image vincentjian
2245 6

Trying to add menuitem with image and having no label in it.

<borderlayout>
    <north>
        <menubar>   
            <menuitem image="/test/image.gif" onClick="@command('doSomething')"/>
            <menuitem />
        </menubar>
    </north>
    ..
    ..
</borderlayout>

if i add a image without any label it cuts the image from both sides(right and bottom) ,and if i use some text in label the full image is shown ,

my problem is i have to show a menuitem with only image on it and no text. I can't change the size of image.

The following code works but i don't want to add label

<borderlayout>
    <north>
        <menubar>   
            <menuitem label="a" image="/test/image.gif" onClick="@command('doSomething')"/>
            <menuitem />
        </menubar>
    </north>
    ..
    ..
</borderlayout>

does anybody know how to do it?

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-03-15 02:29:38 +0800

vincentjian gravatar image vincentjian
2245 6

updated 2013-03-19 04:06:48 +0800

Specify custom-attributes org.zkoss.zul.image.preload to make sure the image is loaded then render the menu item.

<menubar>
    <custom-attributes org.zkoss.zul.image.preload="true" />
    <meunitem image="/test/image.gif" />
</menubar>

EDIT

The image is added as an background-image of HTML element. Therefore, you have to override the style and assign the size of the image to the correspond HTML element.

<style>
    .z-menuitem-btn {
        width: 16px !important;
        height: 16px;
    }
</style>
link publish delete flag offensive edit

Comments

it's not working.

hswain ( 2013-03-15 05:31:36 +0800 )edit

Yes,i too tried it,but not working.

nsharma ( 2013-03-15 05:43:13 +0800 )edit

I verify the issue again, please check the edit part.

vincentjian ( 2013-03-19 04:02:09 +0800 )edit

actaully here i am having more than one menuitem in here,so it is overriding the other item,still not working,i think i need to put style on one particular item .

nsharma ( 2013-03-20 09:31:07 +0800 )edit

Thanks for your help.

nsharma ( 2013-03-20 09:37:44 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2013-03-14 12:21:18 +0800

Seen: 143 times

Last updated: Mar 19 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More