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


Java KeyInputEvent类代码示例

本文整理汇总了Java中com.jme3.input.event.KeyInputEvent的典型用法代码示例。如果您正苦于以下问题:Java KeyInputEvent类的具体用法?Java KeyInputEvent怎么用?Java KeyInputEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


KeyInputEvent类属于com.jme3.input.event包,在下文中一共展示了KeyInputEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onKeyEventQueued

import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
private void onKeyEventQueued(KeyInputEvent evt, NiftyInputConsumer nic) {
    int code = evt.getKeyCode();

    if (code == KeyInput.KEY_LSHIFT || code == KeyInput.KEY_RSHIFT) {
        shiftDown = evt.isPressed();
    } else if (code == KeyInput.KEY_LCONTROL || code == KeyInput.KEY_RCONTROL) {
        ctrlDown = evt.isPressed();
    }
    
    KeyboardInputEvent keyEvt = new KeyboardInputEvent(code,
                                                       evt.getKeyChar(),
                                                       evt.isPressed(),
                                                       shiftDown,
                                                       ctrlDown);

    if (nic.processKeyboardEvent(keyEvt)){
        evt.setConsumed();
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:InputSystemJme.java

示例2: forwardEvents

import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
public void forwardEvents(NiftyInputConsumer nic) {
    int queueSize = inputQueue.size();

    for (int i = 0; i < queueSize; i++){
        InputEvent evt = inputQueue.get(i);
        if (evt instanceof MouseMotionEvent){
            onMouseMotionEventQueued( (MouseMotionEvent)evt, nic);
        }else if (evt instanceof MouseButtonEvent){
            onMouseButtonEventQueued( (MouseButtonEvent)evt, nic);
        }else if (evt instanceof KeyInputEvent){
            onKeyEventQueued( (KeyInputEvent)evt, nic);
        }
    }

    inputQueue.clear();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:17,代码来源:InputSystemJme.java

示例3: update

import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
public void update() {
    if (!context.isRenderable())
        return;
    
    Keyboard.poll();
    while (Keyboard.next()){
        int keyCode = Keyboard.getEventKey();
        char keyChar = Keyboard.getEventCharacter();
        boolean pressed = Keyboard.getEventKeyState();
        boolean down = Keyboard.isRepeatEvent();
        long time = Keyboard.getEventNanoseconds();
        KeyInputEvent evt = new KeyInputEvent(keyCode, keyChar, pressed, down);
        evt.setTime(time);
        listener.onKeyEvent(evt);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:17,代码来源:LwjglKeyInput.java

示例4: getAxisKey

import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
/**
 * Handle the Kie as an axis input : return a Vector3f from the kie keyCode.
 *
 * @param kie the KeyInputEvent to handle as an Axis
 * @return UNIT_X for 'x', UNIT_Y for 'y' and UNIT_Z for 'z' kie.
 */
public static Vector3f getAxisKey(KeyInputEvent kie) {
    Vector3f result = Vector3f.ZERO;
    switch (kie.getKeyCode()) {
        case KeyInput.KEY_X:
            result = Vector3f.UNIT_X;
            break;
        case KeyInput.KEY_Y:
            result = Vector3f.UNIT_Y;
            break;
        case KeyInput.KEY_Z:
            result = Vector3f.UNIT_Z;
            break;
    }
    return result;
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:22,代码来源:ShortcutManager.java

示例5: dispatch

import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
protected void dispatch(KeyInputEvent evt) {
    if( !isEnabled() )
        return;
        
    // Intercept for key modifiers
    int code = evt.getKeyCode();
    if( code == KeyInput.KEY_LSHIFT || code == KeyInput.KEY_RSHIFT ) {
        setModifier(KeyModifiers.SHIFT_DOWN, evt.isPressed());
    }
    if( code == KeyInput.KEY_LCONTROL || code == KeyInput.KEY_RCONTROL ) {
        setModifier(KeyModifiers.CONTROL_DOWN, evt.isPressed());
    }        
    if( code == KeyInput.KEY_LMENU || code == KeyInput.KEY_RMENU ) {
        setModifier(KeyModifiers.ALT_DOWN, evt.isPressed());
    }        
        
    ModifiedKeyInputEvent wrapper = null;
    for( KeyListener l : keyListeners.getArray() ) {
        // Only wrap if we will actually deliver
        if( wrapper == null ) {
            wrapper = new ModifiedKeyInputEvent(evt, modifiers);
        }
        l.onKeyEvent(wrapper);
    }
}
 
开发者ID:jMonkeyEngine-Contributions,项目名称:Lemur,代码行数:26,代码来源:KeyInterceptState.java

示例6: onKeyEvent

import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
@Override
public void onKeyEvent( KeyInputEvent evt ) {
    ModifiedKeyInputEvent mEvt = (ModifiedKeyInputEvent)evt;                    
    if( mEvt.isPressed() ) {
        KeyAction key = mEvt.toKeyAction(); //new KeyAction(code, (control?KeyAction.CONTROL_DOWN:0), (shift?KeyAction.SHIFT_DOWN:0) );
        KeyActionListener handler = actionMap.get(key);
        if( handler != null ) {
            handler.keyAction(TextEntryComponent.this, key);
            evt.setConsumed();
            return;
        }

        // Making sure that no matter what, certain
        // characters never make it directly to the
        // document
        if( evt.getKeyChar() >= 32 ) {
            model.insert(evt.getKeyChar());
            evt.setConsumed();
            //resetText(); ...should be automatic now
        }
    }
}
 
开发者ID:jMonkeyEngine-Contributions,项目名称:Lemur,代码行数:23,代码来源:TextEntryComponent.java

示例7: onKeyEvent

import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
@Override
    public void onKeyEvent(KeyInputEvent evt) {
        int kc = evt.getKeyCode();
        if (evt.isPressed()) {
            //controlIsDown = (kc == KeyInput.KEY_LCONTROL || kc == KeyInput.KEY_RCONTROL);
            shiftIsDown = (kc == KeyInput.KEY_LSHIFT || kc == KeyInput.KEY_RSHIFT);
        } else {
            switch (kc) {
                case KeyInput.KEY_LSHIFT:
                case KeyInput.KEY_RSHIFT:
                    shiftIsDown = false;
                    break;
//                case KeyInput.KEY_LCONTROL:
//                case KeyInput.KEY_RCONTROL:
//                    controlIsDown = false;
//                    break;
            }
        }
    }
 
开发者ID:samynk,项目名称:DArtE,代码行数:20,代码来源:SandboxViewport.java

示例8: testDirectUsage

import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
@Test
public void testDirectUsage() {
	// 1. Define action
	@SuppressWarnings("unchecked")
	Observer<Float> observer = mock(Observer.class);

	// 2. map InputEvents --to--> actions (setup InputMapper's mappings)
	sut.mappings.clear();
	sut.map(tmplKeyInputEvent(KeyInput.KEY_0), InputMapperHelpers.isPressedAsOne, observer);

	//3. simulate events
	sut.onEvent(new KeyInputEvent(KeyInput.KEY_0, '0', true, false));
	sut.onEvent(new KeyInputEvent(KeyInput.KEY_0, '0', false, false));

	//4. check
	InOrder inOrder1 = inOrder(observer);
	inOrder1.verify(observer, times(1)).onNext(1.0f);
	inOrder1.verify(observer, times(1)).onNext(0.0f);
	verify(observer, Mockito.never()).onCompleted();
}
 
开发者ID:davidB,项目名称:jme3_skel,代码行数:21,代码来源:InputMapperTest.java

示例9: testIndirectUsage

import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
@Test
public void testIndirectUsage() {
	// 1. Define action (a biz facade points from where 'real' action)
	Subject<Float,Float> actionf0 = PublishSubject.create();

	// 2. map InputEvents --to--> actions (setup InputMapper's mappings)
	sut.mappings.clear();
	sut.map(tmplKeyInputEvent(KeyInput.KEY_0), InputMapperHelpers.isPressedAsOne, actionf0);

	// 3. map actions --to--> subscribe listener/observer
	@SuppressWarnings("unchecked")
	Observer<Float> observer = mock(Observer.class);
	actionf0.subscribe(observer);

	sut.onEvent(new KeyInputEvent(KeyInput.KEY_0, '0', true, false));
	sut.onEvent(new KeyInputEvent(KeyInput.KEY_0, '0', false, false));

	InOrder inOrder1 = inOrder(observer);
	inOrder1.verify(observer, times(1)).onNext(1.0f);
	inOrder1.verify(observer, times(1)).onNext(0.0f);
	verify(observer, Mockito.never()).onCompleted();
}
 
开发者ID:davidB,项目名称:jme3_skel,代码行数:23,代码来源:InputMapperTest.java

示例10: checkCommandKey

import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
private boolean checkCommandKey(KeyInputEvent kie) {
    if (kie.getKeyCode() == KeyInput.KEY_D) {
        if (shiftDown) {
            duplicateSelected();
            return true;
        }
    }
    // X will only delete if the user isn't already transforming
    if (currentState == null && kie.getKeyCode() == KeyInput.KEY_X) {
        if (!ctrlDown && !shiftDown) {
            deleteSelected();
            return true;
        }
    }
    return false;
}
 
开发者ID:maany,项目名称:jME-CinematicEditor,代码行数:17,代码来源:SelectTool.java

示例11: checkStateKey

import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
private boolean checkStateKey(KeyInputEvent kie) {
    Spatial selected = toolController.getSelectedSpatial();
    if (kie.getKeyCode() == KeyInput.KEY_G) {
        currentState = State.translate;
        MoveManager moveManager = Lookup.getDefault().lookup(MoveManager.class);
        moveManager.reset();
        Quaternion rot = camera.getRotation().mult(new Quaternion().fromAngleAxis(FastMath.PI, Vector3f.UNIT_Y));
        moveManager.initiateMove(selected, rot, false);
        moving = moveManager.makeUndo();
        return true;
    } else if (kie.getKeyCode() == KeyInput.KEY_R) {
        currentState = State.rotate;
        return true;
    } else if (kie.getKeyCode() == KeyInput.KEY_S) {
        currentState = State.scale;
        return true;
    }
    return false;
}
 
开发者ID:maany,项目名称:jME-CinematicEditor,代码行数:20,代码来源:SelectTool.java

示例12: checkAxisKey

import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
private boolean checkAxisKey(KeyInputEvent kie) {
    if (kie.getKeyCode() == KeyInput.KEY_X) {
        currentAxis = Vector3f.UNIT_X;
        checkMovePlane(MoveManager.XY, MoveManager.XZ);
        return true;
    } else if (kie.getKeyCode() == KeyInput.KEY_Y) {
        currentAxis = Vector3f.UNIT_Y;
        checkMovePlane(MoveManager.XY, MoveManager.YZ);
        return true;
    } else if (kie.getKeyCode() == KeyInput.KEY_Z) {
        currentAxis = Vector3f.UNIT_Z;
        checkMovePlane(MoveManager.XZ, MoveManager.YZ);
        return true;
    }
    return false;
}
 
开发者ID:maany,项目名称:jME-CinematicEditor,代码行数:17,代码来源:SelectTool.java

示例13: onKeyEvent

import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
@Override
public void onKeyEvent(KeyInputEvent evt) {
    if (evt.isReleased())
        return;
    if (evt.getKeyChar() == '\n' || evt.getKeyChar() == '\r') {
        txt3.setText(str.toString());
        str.setLength(0);
    } else {
        str.append(evt.getKeyChar());
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:12,代码来源:TestBitmapFont.java

示例14: onKeyEventQueued

import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
private void onKeyEventQueued(KeyInputEvent evt) {
    if (evt.isRepeating()) {
        return; // repeat events not used for bindings
    }
    
    int hash = KeyTrigger.keyHash(evt.getKeyCode());
    invokeActions(hash, evt.isPressed());
    invokeTimedActions(hash, evt.getTime(), evt.isPressed());
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:InputManager.java

示例15: onKeyEvent

import com.jme3.input.event.KeyInputEvent; //导入依赖的package包/类
/**
 * Callback from RawInputListener. Do not use.
 */
public void onKeyEvent(KeyInputEvent evt) {
    if (!eventsPermitted) {
        throw new UnsupportedOperationException("KeyInput has raised an event at an illegal time.");
    }

    inputQueue.add(evt);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:11,代码来源:InputManager.java


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