use of com.codename1.ui.events.ActionEvent in project CodenameOne by codenameone.
the class SideMenuBar method closeCurrentMenu.
/**
* Folds the current side menu if it is open, when the menu is closed it
* will invoke the runnable callback method
*
* @param callback will be invoked when the menu is actually closed
*/
public static void closeCurrentMenu(final Runnable callback) {
if (Toolbar.isOnTopSideMenu() && (Toolbar.isGlobalToolbar() || Display.getInstance().getCommandBehavior() != Display.COMMAND_BEHAVIOR_SIDE_NAVIGATION)) {
Display.getInstance().getCurrent().getToolbar().closeSideMenu();
callback.run();
return;
}
Form f = Display.getInstance().getCurrent();
final SideMenuBar b = (SideMenuBar) f.getClientProperty("cn1$sideMenuParent");
if (b != null && !b.transitionRunning) {
b.parent.addShowListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
b.parent.removeShowListener(this);
callback.run();
}
});
b.closeMenu();
} else {
callback.run();
}
}
use of com.codename1.ui.events.ActionEvent in project CodenameOne by codenameone.
the class Tabs method insertTab.
/**
* Inserts a <code>component</code>, at <code>index</code>,
* represented by a <code>button</code>
* Uses java.util.Vector internally, see <code>insertElementAt</code>
* for details of insertion conventions.
* The Button styling will be associated with "Tab" UIID.
*
* @param tab represents the tab on top
* @param component The component to be displayed when this tab is clicked.
* @param index the position to insert this new tab
*
* @see #addTab
* @see #removeTabAt
* @deprecated should use radio button as an argument
*/
public void insertTab(Component tab, Component component, int index) {
checkIndex(index);
if (component == null) {
return;
}
final Component b = tab;
if (tabUIID != null) {
b.setUIID(tabUIID);
}
b.addFocusListener(focusListener);
bindTabActionListener(b, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (selectedTab != null) {
if (tabUIID != null) {
selectedTab.setUIID(tabUIID);
}
if (!animateTabSelection) {
selectedTab.setShouldCalcPreferredSize(true);
selectedTab.repaint();
}
int previousSelectedIndex = tabsContainer.getComponentIndex(selectedTab);
// this might happen if a tab was removed
if (previousSelectedIndex != -1) {
Component previousContent = contentPane.getComponentAt(previousSelectedIndex);
if (previousContent instanceof Container) {
((Container) previousContent).setBlockFocus(true);
}
}
}
active = tabsContainer.getComponentIndex(b);
Component content = contentPane.getComponentAt(active);
if (content instanceof Container) {
((Container) content).setBlockFocus(false);
}
setSelectedIndex(active, animateTabSelection);
initTabsFocus();
selectedTab = b;
if (!animateTabSelection) {
selectedTab.setShouldCalcPreferredSize(true);
tabsContainer.revalidate();
}
tabsContainer.scrollComponentToVisible(selectedTab);
}
});
if (component instanceof Container) {
((Container) component).setBlockFocus(true);
}
tabsContainer.addComponent(index, b);
contentPane.addComponent(index, component);
setTabsLayout(tabPlacement);
if (tabsContainer.getComponentCount() == 1) {
selectedTab = tabsContainer.getComponentAt(0);
if (component instanceof Container) {
((Container) component).setBlockFocus(false);
}
initTabsFocus();
}
checkTabsCanBeSeen();
}
use of com.codename1.ui.events.ActionEvent in project CodenameOne by codenameone.
the class SwipeableContainer method animate.
@Override
public boolean animate() {
if (openCloseMotion != null) {
int val = openCloseMotion.getValue();
if (openedToRight) {
topWrapper.setX(val);
} else {
topWrapper.setX(-val);
}
repaint();
boolean finished = openCloseMotion.isFinished();
if (finished) {
// getComponentForm().deregisterAnimated(this);
openCloseMotion = null;
if (!open) {
bottomRightWrapper.setVisible(false);
bottomLeftWrapper.setVisible(false);
openedToLeft = false;
openedToRight = false;
} else {
dispatcher.fireActionEvent(new ActionEvent(this, ActionEvent.Type.Swipe));
}
}
return !finished;
}
return false;
}
use of com.codename1.ui.events.ActionEvent in project CodenameOne by codenameone.
the class TextArea method fireActionEvent.
/**
* Notifies listeners of a change to the text area
*/
void fireActionEvent() {
if (actionListeners != null) {
ActionEvent evt = new ActionEvent(this, ActionEvent.Type.Edit);
actionListeners.fireActionEvent(evt);
}
if (bindListeners != null) {
String t = getText();
bindListeners.fireBindTargetChange(this, "text", lastTextValue, t);
lastTextValue = t;
}
}
use of com.codename1.ui.events.ActionEvent in project CodenameOne by codenameone.
the class HTMLImageMap method actionPerformed.
public void actionPerformed(ActionEvent evt) {
if (mapData != null) {
int x = evt.getX();
int y = evt.getY();
if ((mapData.areas != null) && (x != -1)) {
for (Enumeration e = mapData.areas.keys(); e.hasMoreElements(); ) {
Rectangle rect = (Rectangle) e.nextElement();
if (rect.contains(x - getAbsoluteX(), y - getAbsoluteY())) {
String link = (String) mapData.areas.get(rect);
if (link != null) {
HTMLLink.processLink(htmlC, link);
}
return;
}
}
}
if (mapData.defaultLink != null) {
HTMLLink.processLink(htmlC, mapData.defaultLink);
}
}
}
Aggregations