本文整理汇总了Java中processing.event.KeyEvent类的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent类的具体用法?Java KeyEvent怎么用?Java KeyEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KeyEvent类属于processing.event包,在下文中一共展示了KeyEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: keyEvent
import processing.event.KeyEvent; //导入依赖的package包/类
/**
* Adding key support. up and down arrows can be used to scroll listbox or dropdownList,up and
* down, use shift+up/down for faster scrolling, use alt+up/down to jump to the top or bottom.
*
* @exclude {@inheritDoc}
*/
@ControlP5.Invisible public void keyEvent(final KeyEvent theEvent) {
super.keyEvent(theEvent);
float x = getAbsolutePosition().x;
float y = getAbsolutePosition().y;
boolean b = (getWindow().mouseX > x && getWindow().mouseX < (x + _myWidth) && getWindow().mouseY > (y - getBarHeight()) && getWindow().mouseY < y + _myOriginalBackgroundHeight);
if (b && isOpen()) {
float step = (1.0f / (float) items.size());
if (cp5.isShiftDown()) {
step *= 10;
}
else if (cp5.isAltDown()) {
step = 1;
}
if (theEvent.getAction() == KeyEvent.PRESS) {
switch (theEvent.getKeyCode()) {
case (PApplet.UP):
_myScrollbar.setValue(PApplet.constrain(_myScrollbar.getValue() + step, 0, 1));
break;
case (PApplet.DOWN):
_myScrollbar.setValue(PApplet.constrain(_myScrollbar.getValue() - step, 0, 1));
break;
}
}
}
}
示例2: keyEvent
import processing.event.KeyEvent; //导入依赖的package包/类
/**
* Adding key support. up and down arrows can be used to scroll listbox or dropdownList,up and
* down, use shift+up/down for faster scrolling, use alt+up/down to jump to the top or bottom.
*
* @exclude {@inheritDoc}
*/
@ControlP5.Invisible public void keyEvent(final KeyEvent theEvent) {
super.keyEvent(theEvent);
float x = getAbsolutePosition().x;
float y = getAbsolutePosition().y;
boolean b = (getWindow().mouseX > x && getWindow().mouseX < (x + _myWidth) && getWindow().mouseY > (y - getBarHeight()) && getWindow().mouseY < y
+ _myOriginalBackgroundHeight);
if (b && isOpen()) {
float step = (1.0f / (float) items.size());
if (cp5.isShiftDown()) {
step *= 10;
} else if (cp5.isAltDown()) {
step = 1;
}
if (theEvent.getAction() == KeyEvent.PRESS) {
switch (theEvent.getKeyCode()) {
case (PApplet.UP):
_myScrollbar.setValue(PApplet.constrain(_myScrollbar.getValue() + step, 0, 1));
break;
case (PApplet.DOWN):
_myScrollbar.setValue(PApplet.constrain(_myScrollbar.getValue() - step, 0, 1));
break;
}
}
}
}
示例3: nativeKeyEvent
import processing.event.KeyEvent; //导入依赖的package包/类
protected void nativeKeyEvent(com.jogamp.newt.event.KeyEvent nativeEvent,
int peAction) {
int peModifiers = nativeEvent.getModifiers() &
(InputEvent.SHIFT_MASK |
InputEvent.CTRL_MASK |
InputEvent.META_MASK |
InputEvent.ALT_MASK);
char keyChar;
if ((int)nativeEvent.getKeyChar() == 0) {
keyChar = PConstants.CODED;
} else {
keyChar = nativeEvent.getKeyChar();
}
KeyEvent ke = new KeyEvent(nativeEvent, nativeEvent.getWhen(),
peAction, peModifiers,
keyChar,
nativeEvent.getKeyCode());
pg.parent.postEvent(ke);
}
示例4: keyEvent
import processing.event.KeyEvent; //导入依赖的package包/类
public void keyEvent( KeyEvent theKeyEvent ) {
if ( isInside && theKeyEvent.getAction( ) == KeyEvent.PRESS ) {
switch ( theKeyEvent.getKeyCode( ) ) {
case ( ControlP5.UP ):
scroll( theKeyEvent.isAltDown( ) ? -itemIndexOffset : theKeyEvent.isShiftDown( ) ? -10 : -1 );
updateHover( );
break;
case ( ControlP5.DOWN ):
scroll( theKeyEvent.isAltDown( ) ? items.size( ) - itemRange : theKeyEvent.isShiftDown( ) ? 10 : 1 );
updateHover( );
break;
case ( ControlP5.LEFT ):
break;
case ( ControlP5.RIGHT ):
break;
case ( ControlP5.ENTER ):
onRelease( );
break;
}
}
}
示例5: keyEvent
import processing.event.KeyEvent; //导入依赖的package包/类
public void keyEvent(final KeyEvent e)
{
if(e.getKey() == 's')
{
if(e.getAction() == KeyEvent.RELEASE)
spectate(null);
}
else if(e.getKeyCode() == 19)
{
if(e.getAction() == KeyEvent.PRESS)
{
pauseInput();
}
}
else if(e.getKey() == 'r')
{
if(e.getAction() == KeyEvent.RELEASE)
{
//resetSystem();
}
}
else
{
viewerFeedKeyboard(e);
}
}
示例6: keyEvent
import processing.event.KeyEvent; //导入依赖的package包/类
public void keyEvent(KeyEvent e) {
if(e.getAction() == KeyEvent.PRESS) {
if(e.getKeyCode() == P.UP || e.getKeyCode() == P.LEFT || e.getKeyCode() == P.RIGHT || e.getKeyCode() == P.DOWN) lastMouseTime = P.p.millis();
Point translatePoint = new Point(0, 0);
if(e.getKeyCode() == P.UP) translatePoint.setLocation(0, -1);
if(e.getKeyCode() == P.LEFT) translatePoint.setLocation(-1, 0);
if(e.getKeyCode() == P.RIGHT) translatePoint.setLocation(1, 0);
if(e.getKeyCode() == P.DOWN) translatePoint.setLocation(0, 1);
if(DRAGGING_POINT == _points[0] || DRAGGING_POINT == _points[1] || DRAGGING_POINT == _points[2] || DRAGGING_POINT == _points[3]) {
DRAGGING_POINT.translate(translatePoint.x, translatePoint.y);
} else if(DRAGGING_QUAD == this) {
for( int i=0; i < _points.length; i++ ) {
_points[i].translate(translatePoint.x, translatePoint.y);
}
}
}
}
示例7: dequeueEvents
import processing.event.KeyEvent; //导入依赖的package包/类
protected void dequeueEvents() {
// can't do this.. thread lock
// synchronized (eventQueue) {
// for (int i = 0; i < eventCount; i++) {
// Event e = eventQueue[i];
while (eventQueue.available()) {
final Event e = eventQueue.remove();
switch (e.getFlavor()) {
case Event.MOUSE:
handleMouseEvent((MouseEvent) e);
break;
case Event.KEY:
handleKeyEvent((KeyEvent) e);
break;
}
// }
// eventCount = 0;
}
}
示例8: nativeKeyEvent
import processing.event.KeyEvent; //导入依赖的package包/类
protected void nativeKeyEvent(final java.awt.event.KeyEvent event) {
int peAction = 0;
switch (event.getID()) {
case java.awt.event.KeyEvent.KEY_PRESSED:
peAction = KeyEvent.PRESS;
break;
case java.awt.event.KeyEvent.KEY_RELEASED:
peAction = KeyEvent.RELEASE;
break;
case java.awt.event.KeyEvent.KEY_TYPED:
peAction = KeyEvent.TYPE;
break;
}
// int peModifiers = event.getModifiersEx() &
// (InputEvent.SHIFT_DOWN_MASK |
// InputEvent.CTRL_DOWN_MASK |
// InputEvent.META_DOWN_MASK |
// InputEvent.ALT_DOWN_MASK);
final int peModifiers = event.getModifiers()
& (InputEvent.SHIFT_MASK | InputEvent.CTRL_MASK | InputEvent.META_MASK | InputEvent.ALT_MASK);
this.postEvent(new KeyEvent(event, event.getWhen(), peAction, peModifiers, event.getKeyChar(), event
.getKeyCode()));
}
示例9: keyEvent
import processing.event.KeyEvent; //导入依赖的package包/类
@Override
public void keyEvent(KeyEvent event){
switch(event.getAction()){
case KeyEvent.PRESS:
key_combi_active = ((key_combi ^ event.getModifiers()) == 0);
break;
case KeyEvent.RELEASE:
key_combi_active = false;
break;
}
}
示例10: keyEvent
import processing.event.KeyEvent; //导入依赖的package包/类
@Override
public void keyEvent(KeyEvent event){
switch(event.getAction()){
case KeyEvent.PRESS:
key_combi_active = false;
break;
case KeyEvent.RELEASE:
key_combi_active = true;
break;
}
}
示例11: keyEvent
import processing.event.KeyEvent; //导入依赖的package包/类
public void keyEvent(KeyEvent e) {
if (e.getAction() == KeyEvent.PRESS) {
onKeyPress();
} else if (e.getAction() == KeyEvent.RELEASE) {
onKeyRelease();
}
}
示例12: keyEvent
import processing.event.KeyEvent; //导入依赖的package包/类
public void keyEvent(KeyEvent theKeyEvent) {
if (isUserInteraction && isTexfieldActive && isActive && theKeyEvent.getAction() == KeyEvent.PRESS) {
if (ignorelist.contains(cp5.getKeyCode())) {
return;
}
if (keyMapping.containsKey(cp5.getKeyCode())) {
keyMapping.get(cp5.getKeyCode()).execute();
} else {
keyMapping.get(DEFAULT).execute();
}
}
}
示例13: keyPressed
import processing.event.KeyEvent; //导入依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {
super.keyPressed();
if(key == ' ') {
// snapshot raster graphics + code
snapshot();
}
else if(key == 'p') {
// snapshot a pdf + code
recordPdf = true;
pdfTime = now();
snapshotCode(pdfTime);
}
}
示例14: keyPressed
import processing.event.KeyEvent; //导入依赖的package包/类
@Override
public void keyPressed(KeyEvent event) {
super.keyPressed(event);
if (key == 'r' || key == 'R') {
triggerRender = true;
}
}
示例15: keyEvent
import processing.event.KeyEvent; //导入依赖的package包/类
public void keyEvent( KeyEvent theKeyEvent ) {
if ( isUserInteraction && isTexfieldActive && isActive && theKeyEvent.getAction( ) == KeyEvent.PRESS ) {
if ( ignorelist.contains( cp5.getKeyCode( ) ) ) {
return;
}
if ( keyMapping.containsKey( cp5.getKeyCode( ) ) ) {
keyMapping.get( cp5.getKeyCode( ) ).execute( );
} else {
keyMapping.get( DEFAULT ).execute( );
}
}
}