|
Processing... Right click (or long press on tablets) on a car to show context menus.
Description & Source Code
demo.zul
<window title="ZK Car Catalog Management Console" border="normal" width="600px" apply="demo.getting_started.menu_toolbar.MenuController"> <style src="/widgets/getting_started/menu_toolbar/style.css" /> <menubar autodrop="true"> <menu label="Car"> <menupopup> <menu label="New"> <menupopup> <menuitem label="Small Car" /> <menuitem label="Medium Car" /> <menuitem label="Large Car" /> </menupopup> </menu> <menuitem label="Search" /> </menupopup> </menu> <menu label="Edit"> <menupopup> <menuitem label="Undo" image="/widgets/getting_started/menu_toolbar/img/edit_undo.png" /> <menuitem label="Redo" disabled="true" image="/widgets/getting_started/menu_toolbar/img/edit_redo.png" /> <menuseparator /> <menuitem label="Cut" image="/widgets/getting_started/menu_toolbar/img/edit_cut.png" /> <menuitem label="Copy" image="/widgets/getting_started/menu_toolbar/img/edit_copy.png" /> <menuitem label="Paste" image="/widgets/getting_started/menu_toolbar/img/edit_paste.png" /> <menuseparator /> <menuitem label="Select All" image="/widgets/getting_started/menu_toolbar/img/edit_select-all.png" /> </menupopup> </menu> <menu label="View"> <menupopup> <menuitem label="Sort by Name" checkmark="true" autocheck="true" /> <menuitem label="Sort by Date" checkmark="true" autocheck="true" /> </menupopup> </menu> <menu label="Help"> <menupopup> <menuitem label="Help Content" /> <menuitem label="About" /> </menupopup> </menu> </menubar> <toolbar> <toolbarbutton image="/widgets/getting_started/menu_toolbar/img/file_new.png" tooltiptext="New"/> <toolbarbutton image="/widgets/getting_started/menu_toolbar/img/edit_undo.png" tooltiptext="Undo"/> <toolbarbutton image="/widgets/getting_started/menu_toolbar/img/edit_cut.png" tooltiptext="Cut"/> <toolbarbutton image="/widgets/getting_started/menu_toolbar/img/edit_copy.png" tooltiptext="Copy"/> <toolbarbutton image="/widgets/getting_started/menu_toolbar/img/edit_paste.png" tooltiptext="Paste"/> </toolbar> <menupopup id="editPopup"> <menuitem label="View" /> <menuitem label="Edit" /> <menuitem label="Delete" /> </menupopup> <image src="/widgets/getting_started/img/car1.png" width="140px" sclass="icon" tooltiptext="Right click to show menu" context="editPopup" /> <image src="/widgets/getting_started/img/car2.png" width="140px" sclass="icon" tooltiptext="Right click to show menu" context="editPopup" /> <image src="/widgets/getting_started/img/car3.png" width="140px" sclass="icon" tooltiptext="Right click to show menu" context="editPopup" /> <image src="/widgets/getting_started/img/car4.png" width="140px" sclass="icon" tooltiptext="Right click to show menu" context="editPopup" /> <image src="/widgets/getting_started/img/car5.png" width="140px" sclass="icon" tooltiptext="Right click to show menu" context="editPopup" /> <image src="/widgets/getting_started/img/car6.png" width="140px" sclass="icon" tooltiptext="Right click to show menu" context="editPopup" /> <hlayout sclass="taskbar"> <button iconSclass="z-icon-windows" /> <button id="left" label="Cars on Sale" iconSclass="z-icon-dollar"/> <button id="right" label="50% Off with Card" iconSclass="z-icon-credit-card" dir="reverse"/> </hlayout> </window> MenuController.java
package demo.getting_started.menu_toolbar; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.event.MouseEvent; import org.zkoss.zk.ui.select.SelectorComposer; import org.zkoss.zk.ui.select.annotation.Listen; import org.zkoss.zk.ui.util.Clients; import org.zkoss.zul.impl.LabelElement; public class MenuController extends SelectorComposer<Component> { private static final long serialVersionUID = 1L; @Listen("onClick = menuitem") public void menuAction(MouseEvent event){ showNotify("Clicked on "+((LabelElement)event.getTarget()).getLabel()); } @Listen("onClick = toolbarbutton") public void toolbarAction(MouseEvent event){ showNotify("Clicked on "+((LabelElement)event.getTarget()).getTooltiptext()); } @Listen("onClick = button") public void buttonAction(){ showNotify("Switch to a task."); } private void showNotify(String msg){ Clients.showNotification(msg,"info",null,null,1000); } }
Copyright © 2005-2024 Potix Corporation All rights reserved.
|
Processing... |