//----------------------------------------------------------------------------
// COMPONENT NAME: LPEX Editor
//
// © Copyright IBM Corporation 2005, 2006
// All Rights Reserved.
//
// DESCRIPTION:
// BlockNewMarkToMouseAction - sample user-defined action (blockNewMarkToMouse)
//----------------------------------------------------------------------------
package com.ibm.lpex.samples;
import com.ibm.lpex.core.LpexAction;
import com.ibm.lpex.core.LpexView;
/**
* Sample action <b>blockNewMarkToMouse</b> - start new selections on new mouse
* drags.
*
* <p>LPEX non-stream selections are by default <i>extended</i> on mouse drags.
* They must be explicitly cleared (with, for example, Alt+U) before marking
* a new block. This action is similar to the <b>blockMarkToMouse</b> default
* editor action, but it makes a new mouse button 1 drag start a new selection.</p>
*
* <p>Here is the BlockNewMarkToMouseAction
* <a href="doc-files/BlockNewMarkToMouseAction.java.html">source code</a>.</p>
*
* <p>To redefine the default <b>blockMarkToMouse</b> action:
* <ul>
* <li>Register this new action implementation via the editor preference page,
* where available, or from the editor command line:
* <pre>set actionClass.blockMarkToMouse com.ibm.lpex.samples.BlockNewMarkToMouseAction</pre></li>
* </ul></p>
*
* @see MouseReselect
* @see com.ibm.lpex.samples All the samples
*/
public class BlockNewMarkToMouseAction implements LpexAction
{
/**
* Runs the action. It ensures that our {@linkplain MouseReselect
* mouse-reselect} tracking of mouse events is installed in this view,
* and lets the editor do its regular <b>blockMarkToMouse</b> action.
*/
public void doAction(LpexView lpexView)
{
MouseReselect.install(lpexView);
lpexView.doDefaultAction(lpexView.actionId("blockMarkToMouse"));
}
/**
* Returns the availability of this action. This action can be
* run whenever editor's default <b>blockMarkToMouse</b> can.
*/
public boolean available(LpexView lpexView)
{
return lpexView.defaultActionAvailable(lpexView.actionId("blockMarkToMouse"));
}
}