Tema: Re: Java 1.00 Appletai - kaip suzinoti kuris peles mygtukas paspaustas?
Autorius: Rimantas Liubertas
Data: 2010-04-14 23:25:10
>      Darau cia si ta su senaja java platforma per java.awt.Applet eventus:
>
>      public boolean mouseDown(Event e, int x, int y);
>      public boolean mouseUp(Event e, int x, int y);
>

Tokie dalykai paprastai būna prie Event. Eini dokumentacijoj žiūri:

@Deprecated
public boolean mouseDown(Event evt,
                                     int x,
                                     int y)
Deprecated. As of JDK version 1.1, replaced by 
processMouseEvent(MouseEvent).

And „Event“ yra nuoroda, spaudi ją, žiūri:

modifiers

public int modifiers
The state of the modifier keys. This is replaced with 
InputEvent.getModifiers() In java 1.1 MouseEvent and KeyEvent are 
subclasses of InputEvent.

META_MASK
public static final int META_MASK
<…>
For mouse events, this flag indicates that the right button was pressed 
or released.

public static final int ALT_MASK
<…>
For mouse events, this flag indicates that the middle mouse button was 
pressed or released.

Ergo:

public boolean mouseDown (Event e, int x, int y) {
     if (e.modifiers == Event.META_MASK) {
	// dešinio mygtuko kodas
     } else if (e.modifiers == Event.ALT_MASK) {
	// vidurinio mygtuko kodas
     } else {
        // kairio mygtuko kodas
     }
<…>
}



ic
--
http://rimantas.com/