当前位置: 首页>>代码示例>>Java>>正文


Java KeyEvent类代码示例

本文整理汇总了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;
            }
        }
    }
}
 
开发者ID:d2fn,项目名称:passage,代码行数:32,代码来源:ListBox.java

示例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;
            }
        }
    }
}
 
开发者ID:d2fn,项目名称:passage,代码行数:32,代码来源:DropdownList.java

示例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);
}
 
开发者ID:d2fn,项目名称:passage,代码行数:23,代码来源:PJOGL.java

示例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;
        }
    }
}
 
开发者ID:sojamo,项目名称:controlp5,代码行数:22,代码来源:ListBox.java

示例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);
    }
}
 
开发者ID:Threepud,项目名称:Sketchup-Blocks,代码行数:27,代码来源:SessionManager.java

示例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);
            }
        }
    }
}
 
开发者ID:cacheflowe,项目名称:haxademic,代码行数:19,代码来源:PGraphicsKeystone.java

示例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;
    }
}
 
开发者ID:aarongolliver,项目名称:FractalFlameV3,代码行数:21,代码来源:PApplet.java

示例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()));
}
 
开发者ID:aarongolliver,项目名称:FractalFlameV3,代码行数:26,代码来源:PApplet.java

示例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;
  }
 
}
 
开发者ID:diwi,项目名称:LiquidFunProcessing,代码行数:13,代码来源:DwParticleDestroyer.java

示例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;
  }
}
 
开发者ID:diwi,项目名称:LiquidFunProcessing,代码行数:12,代码来源:DwMouseDragParticles.java

示例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();
    }
}
 
开发者ID:daveho,项目名称:FunWithSound,代码行数:8,代码来源:FunWithSound.java

示例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();
                }
        }
}
 
开发者ID:d2fn,项目名称:passage,代码行数:13,代码来源:Textfield.java

示例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);
    }
}
 
开发者ID:d2fn,项目名称:passage,代码行数:15,代码来源:Sketch.java

示例14: keyPressed

import processing.event.KeyEvent; //导入依赖的package包/类
@Override
public void keyPressed(KeyEvent event) {
    super.keyPressed(event);
    if (key == 'r' || key == 'R') {
        triggerRender = true;
    }
}
 
开发者ID:d2fn,项目名称:passage,代码行数:8,代码来源:JoonsSketch.java

示例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( );
        }
    }
}
 
开发者ID:sojamo,项目名称:controlp5,代码行数:13,代码来源:Textfield.java


注:本文中的processing.event.KeyEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。