Announcement
Collapse
No announcement yet.
X
-
A new API TabSet.addTabContextMenuHandler(..) has been added in the latest nightly that will allow you to register a context menu listener with access to the tab where the mouse has been right-clicked. See TabContextMenuEvent.getTab
-
Here's some code for you to base on.
It creates a MenuItem which you can put in a Menu and add it as control on your TabSet.
- It checks if the menu item is enabled (at least one tab must be closeable).
- The onClick removes all other tabs but the selected one.
Code:staticTabMenu[1] = new MenuItem("Close Others"); staticTabMenu[1].setEnableIfCondition(new MenuItemIfFunction() { public boolean execute(Canvas target, Menu menu, MenuItem item) { String selectedTab = getSelectedTab().getID(); for (Tab t : getTabs()) { if (t.getID().equals(selectedTab)) continue; if (t.getCanClose()) return true; } return false; } }); staticTabMenu[1].addClickHandler(new ClickHandler() { public void onClick(MenuItemClickEvent event) { String selectedTab = getSelectedTab().getID(); for (Tab t : getTabs()) { if (t.getCanClose() && !t.getID().equals(selectedTab)) { removeTab(t); } } } });
Leave a comment:
-
TabSet (close other tabs feature)
Hello, guys!
I need to implement a part of web app. functionality:
When i'm clicking the right mouse button I need to close all tabs that is not under mouse pointer now ("close other tabs").
BUT! Not -- "selected" tab (result of tabset.getSelectedTab()) must stay alive,
but "tab that mouse pointer aimed on".
Environment: SmartGWT 2.2.
Anyone have an idea how can I reach that?Tags: None
Leave a comment: