PenProfile 2.x

com.livescribe.ext.ui
Class MenuBookmarkHandlerPlugin

java.lang.Object
  extended by com.livescribe.penlet.PenletPlugin
      extended by com.livescribe.penlet.AbstractPenletPlugin
          extended by com.livescribe.ext.ui.MenuBookmarkHandlerPlugin

public class MenuBookmarkHandlerPlugin
extends AbstractPenletPlugin

A plugin that handles menu bookmark activation. This does not consume any events.

When the user taps on a bookmarked region, the following things happen:

  1. The select sound is played if set,
  2. The bookmarked menu item is shown, and
  3. If the bookmark was configured to be selected when activated, then either the forward or select sound is played, depending on whether the menu has a submenu or not.

A usage example:

MenuBookmarkHandlerPlugin mbh = new MenuBookmarkHandlerPlugin(this);
context.installPlugin(mbh);
mbh.activate();
…
myMenu.add("Info");
mbh.registerLast(myMenu, new BookmarkInfo(4, "INFO"));
myMenu.add("About");
mbh.registerLast(myMenu, new BookmarkInfo(5, "ABOUT"));

Since:
2.3
See Also:
setForwardAPM(String), setSelectAPM(String), PenletContext.installPlugin(PenletPlugin)

Field Summary
 
Fields inherited from class com.livescribe.penlet.AbstractPenletPlugin
active, listeners
 
Constructor Summary
MenuBookmarkHandlerPlugin(Penlet penlet)
          Creates a new handler for activating menu bookmarks.
 
Method Summary
 boolean onPenTipEvent(PenTipEvent ev)
          This processes pen-down events but does not consume them.
 void register(Menu menu, int index, Bookmarkable b, boolean doSelect)
          Registers a menu item with this plugin so that when it is activated with a button tap, it is displayed properly.
 void registerLast(Menu menu, Bookmarkable b, boolean doSelect)
          Registers the last item in the menu.
 void setForwardAPM(String clip)
          Sets the sound to play when a menu item's submenu is followed.
 void setParentHoldTime(long time)
          Sets the amount of time to pause at the parent menu when following into submenus.
 void setSelectAPM(String clip)
          Sets the sound to play when a menu item is selected.
 
Methods inherited from class com.livescribe.penlet.AbstractPenletPlugin
activate, addPluginListener, deactivate, fireActivated, fireDeactivated, isActive, onCoordinateEvent, onDocumentEvent, onMenuEvent, onRegionEvent, onStrokeEvent, removePluginListener, scheduleDeactivation, setConsumeAllEvents
 
Methods inherited from class com.livescribe.penlet.PenletPlugin
getDisplay, getPenlet, restoreDisplay, saveDisplay
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MenuBookmarkHandlerPlugin

public MenuBookmarkHandlerPlugin(Penlet penlet)
Creates a new handler for activating menu bookmarks.

Parameters:
penlet - the associated penlet
Method Detail

register

public void register(Menu menu,
                     int index,
                     Bookmarkable b,
                     boolean doSelect)
Registers a menu item with this plugin so that when it is activated with a button tap, it is displayed properly. This also sets the item as bookmarkable.

If the doSelect parameter is true, then the menu item will be selected when it is activated. This means that it will be as if the user tapped right on the NavPlus when the menu is showing. It also means that if the item has a submenu then it will be followed after showing the item for a small period of time.

This makes use of the Menu.setBookmarkable(int, Bookmarkable) method so it is not necessary to call this yourself.

Parameters:
menu - register this menu
index - the menu item index
b - the Bookmarkable information
doSelect - whether to select the item when it's activated
See Also:
Menu.setBookmarkable(int, Bookmarkable)

registerLast

public void registerLast(Menu menu,
                         Bookmarkable b,
                         boolean doSelect)
Registers the last item in the menu. Please see register(Menu, int, Bookmarkable, boolean) for more details.

Parameters:
menu - register the last item in this menu
b - the Bookmarkable information
doSelect - whether to select the item when it's activated
See Also:
register(Menu, int, Bookmarkable, boolean)

setParentHoldTime

public void setParentHoldTime(long time)
Sets the amount of time to pause at the parent menu when following into submenus. This option is ignored if the item is configured to not be selected when activated. The value is set to zero if the parameter is ≤ zero.

Note that if there is no submenu then there is no pause.

The default is 1000 ms.

Parameters:
time - the pause time, in milliseconds

setSelectAPM

public void setSelectAPM(String clip)
Sets the sound to play when a menu item is selected. This is set to null by default.

This sound will play instead of any sound configured on the menu, even if this is set to null.

Parameters:
clip - the new select sound clip, null to unset
See Also:
Menu.setSelectAPM(String)

setForwardAPM

public void setForwardAPM(String clip)
Sets the sound to play when a menu item's submenu is followed. This is set to null by default.

This sound will play instead of any sound configured on the menu, even if this is set to null.

Parameters:
clip - the new follow sound clip, null to unset
See Also:
Menu.setForwardAPM(String)

onPenTipEvent

public boolean onPenTipEvent(PenTipEvent ev)
This processes pen-down events but does not consume them. They are still passed on to the application since it may still wish to be informed of the button taps.

Menus are selected before the event is passed to the application.

Overrides:
onPenTipEvent in class AbstractPenletPlugin
Parameters:
ev - the pen tip event
Returns:
false indicating that the events will be passed to the application.
See Also:
AbstractPenletPlugin.setConsumeAllEvents(boolean)

PenProfile 2.x

Copyright © 2010 Livescribe Inc. All Rights Reserved.
Confidential and subject to NDA.