Java Reference
In-Depth Information
effort, the resulting behavior can be tailored to the specific application in mind, leading to
a more user friendliness system (Ball & Mirmehdi, 1999).
The steps involved in defining specific mouse navigation behavior are similar to those
for the keyboard discussed in the previous section. However, instead of keyboard events,
we will now need to detect and process mouse events.
An example on having user-defined mouse navigation is provided in the code segment
in Figures 10 and 11. As with other behavior classes, the customized MouseMovement
navigation class includes a constructor, an initialize method to specify the initial wakeup
events, a processStimulus method to detect the exact event and carry out processing when
any of the mouse events has occurred, as well as a support MouseEvent method for carry-
ing out the necessary transform.
Specifically, the processStimulus method in Figure 11 decodes the specific user interac-
tion with the mouse and then invokes the MouseEvent method with the decoded interaction
to carry out the necessary transform. Obviously, it is easy to modify the processStimulus
and MouseEvent methods to include capabilities to change the rate of movement and other
advanced features.
Figure 11. Secondcode segment for MouseNavigation.java
43.
public void processStimulus(Enumeration criteria)
44.
{
45.
WakeupCriterion wakeup; AWTEvent[] event; int eventID;
46.
while(criteria.hasMoreElements())
47.
{
48.
wakeup = (WakeupCriterion) criteria.nextElement();
49.
if(wakeup instanceof WakeupOnAWTEvent)
50.
{
51.
event = ((WakeupOnAWTEvent)wakeup).getAWTEvent();
52.
for(int i=0;i<event.length;i++)
53.
{
54.
eventID = event[i].getID();
55.
if((eventID==MouseEvent.MOUSE_PRESSED)&& !((MouseEvent)event[i]).isAltDown()
56.
&& !((MouseEvent)event[i]).isMetaDown()) MouseEvent(3); // left button
57.
if((eventID==MouseEvent.MOUSE_PRESSED)&& !((MouseEvent)event[i]).isAltDown()
58.
&& ((MouseEvent)event[i]).isMetaDown()) MouseEvent(4); // right button
59.
if((eventID==MouseEvent.MOUSE_PRESSED)&& ((MouseEvent)event[i]).isAltDown()
60.
&& !((MouseEvent)event[i]).isMetaDown()) MouseEvent(1); // center button
61.
if((eventID==MouseEvent.MOUSE_DRAGGED)&& !((MouseEvent)event[i]).isAltDown()
62.
&& !((MouseEvent)event[i]).isMetaDown()) MouseEvent(2); // click and drag
63.
}
64.
}
65.
}
66.
this.wakeupOn(allEvents);
67.
}
Search WWH ::




Custom Search