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


Java KeyEvent.isShiftDown方法代码示例

本文整理汇总了Java中com.jogamp.newt.event.KeyEvent.isShiftDown方法的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.isShiftDown方法的具体用法?Java KeyEvent.isShiftDown怎么用?Java KeyEvent.isShiftDown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jogamp.newt.event.KeyEvent的用法示例。


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

示例1: handleSelection

import com.jogamp.newt.event.KeyEvent; //导入方法依赖的package包/类
private void handleSelection(KeyEvent e) {
    if (e.isControlDown()) {
        if (e.getKeyCode() == KeyEvent.VK_C) {
            if (isAnythingSelected()) {
                clipBoard = getSelectedLines();
            }
        } else if (e.getKeyCode() == KeyEvent.VK_X) {
            if (isAnythingSelected()) {
                clipBoard = getSelectedLines();
                deleteSection(selectionLineStartPosition, selectionLineStopPosition, selectionCursorStartPosition,
                        selectionCursorStopPosition);
            }
        } else if (e.getKeyCode() == KeyEvent.VK_V) {
            pasteClipboard();
        }
    }

    if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
        if (!isAnythingSelected()) {
            selectionCursorStartPosition = cursorPosition;
            selectionLineStartPosition = linePosition;
        }
    } else if (e.isShiftDown() && isMovementKey(e)) {
        selectionCursorStopPosition = cursorPosition;
        selectionLineStopPosition = linePosition;
    } else if (e.getKeyCode() != KeyEvent.VK_CONTROL && !(e.isControlDown() && e.getKeyCode() == KeyEvent.VK_C)) {
        selectionCursorStartPosition = cursorPosition;
        selectionLineStartPosition = linePosition;
        selectionCursorStopPosition = cursorPosition;
        selectionLineStopPosition = linePosition;
    }
}
 
开发者ID:NLeSC,项目名称:Neon,代码行数:33,代码来源:TextEditorKeyboardHandler.java

示例2: forwardEvents

import com.jogamp.newt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void forwardEvents(NiftyInputConsumer inputConsumer)
{
	//Mouse Events
	//Mouse Position
	inputConsumer.processMouseEvent(mouseLoc.x, mouseLoc.y, 0, -1, false);
	
	//Mouse Buttons
	for(int i=0; i<currentMouseButtons.length; i++)
	{
		if(getMouseButtonDown(i))
		{
			if(inputConsumer.processMouseEvent(mouseLoc.x, mouseLoc.y, 0, i, true))
			{	consumeMouseButtonDown(i); }
		}
		
		else if(getMouseButtonUp(i))
		{
			if(inputConsumer.processMouseEvent(mouseLoc.x, mouseLoc.y, 0, i, false))
			{	consumeMouseButtonUp(i); }
		}
	}
	
	//Keyboard events, for this we need the event queue because we need more than just the keyCode or Symbol, we need the entire event
	while(!keyEventQueue.isEmpty())
	{
		KeyEvent kEvt = keyEventQueue.pollLast();
		boolean pressed = (kEvt.getEventType() == KeyEvent.EVENT_KEY_PRESSED);
		KeyboardInputEvent newEvent = new KeyboardInputEvent(converter.convertToNiftyKeyCode(kEvt.getKeyCode(), 0), kEvt.getKeyChar(), pressed, kEvt.isShiftDown(), kEvt.isControlDown());
		
		if(inputConsumer.processKeyboardEvent(newEvent))
		{
			if(pressed)
				consumeKeyDown(kEvt.getKeyCode());
			else
				consumeKeyUp(kEvt.getKeyCode());
		}
	}
}
 
开发者ID:jacquesh,项目名称:project-grige,代码行数:40,代码来源:Input.java

示例3: keyPressed

import com.jogamp.newt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {

	// If an entity has been selected, pass the key event to it
	if (RenderManager.inst().isEntitySelected()) {
		RenderManager.inst().handleKeyPressed(e.getKeyCode(), e.getKeyChar(),
				e.isShiftDown(), e.isControlDown(), e.isAltDown());
		return;
	}

	// If no entity has been selected, the camera will handle the key event
	Vec3d pos = _updateView.getGlobalPosition();
	Vec3d cent = _updateView.getGlobalCenter();

	// Construct a unit vector in the x-y plane in the direction of the view center
	Vec3d forward = new Vec3d(cent);
	forward.sub3(pos);
	forward.z = 0.0d;
	forward.normalize3();

	// Trap the degenerate case where the camera look straight down on the x-y plane
	// For this case the normalize3 method returns a unit vector in the z-direction
	if (forward.z > 0.0)
		forward.set3(1.0d, 0.0d, 0.0d);

	// Construct a unit vector pointing to the left of the direction vector
	Vec3d left = new Vec3d( -forward.y, forward.x, 0.0d);

	// Scale the two vectors to the desired step size
	double inc = Simulation.getIncrementSize();
	forward.scale3(inc);
	left.scale3(inc);

	int keyCode = e.getKeyCode();

	if (keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_A) {
		pos.add3(left);
		cent.add3(left);
	}

	else if (keyCode == KeyEvent.VK_RIGHT || keyCode == KeyEvent.VK_D) {
		pos.sub3(left);
		cent.sub3(left);
	}

	else if (keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_W) {
		if (e.isShiftDown()) {
			pos.set3(pos.x, pos.y, pos.z+inc);
			cent.set3(cent.x, cent.y, cent.z+inc);
		}
		else {
			pos.add3(forward);
			cent.add3(forward);
		}
	}

	else if (keyCode == KeyEvent.VK_DOWN || keyCode == KeyEvent.VK_S) {
		if (e.isShiftDown()) {
			pos.set3(pos.x, pos.y, pos.z-inc);
			cent.set3(cent.x, cent.y, cent.z-inc);
		}
		else {
			pos.sub3(forward);
			cent.sub3(forward);
		}
	}

	else
		return;

	_updateView.updateCenterAndPos(cent, pos);
}
 
开发者ID:jaamsim,项目名称:jaamsim,代码行数:73,代码来源:CameraControl.java

示例4: charPress

import com.jogamp.newt.event.KeyEvent; //导入方法依赖的package包/类
public void charPress(KeyEvent keyEvent) {

        float offset = keyEvent.isShiftDown() ? viewScale.smallPosOffset() : viewScale.largePosOffset();

        if (rightKeyboardCtrls) {

            switch (keyEvent.getKeyCode()) {

                case KeyEvent.VK_I:
                    offsetTargetPos(TargetOffsetDir.FORWARD, offset);
                    break;
                case KeyEvent.VK_K:
                    offsetTargetPos(TargetOffsetDir.BACKWARD, offset);
                    break;
                case KeyEvent.VK_L:
                    offsetTargetPos(TargetOffsetDir.RIGHT, offset);
                    break;
                case KeyEvent.VK_J:
                    offsetTargetPos(TargetOffsetDir.LEFT, offset);
                    break;
                case KeyEvent.VK_O:
                    offsetTargetPos(TargetOffsetDir.UP, offset);
                    break;
                case KeyEvent.VK_U:
                    offsetTargetPos(TargetOffsetDir.DOWN, offset);
                    break;
            }
        } else {

            switch (keyEvent.getKeyCode()) {

                case KeyEvent.VK_W:
                    offsetTargetPos(TargetOffsetDir.FORWARD, offset);
                    break;
                case KeyEvent.VK_S:
                    offsetTargetPos(TargetOffsetDir.BACKWARD, offset);
                    break;
                case KeyEvent.VK_D:
                    offsetTargetPos(TargetOffsetDir.RIGHT, offset);
                    break;
                case KeyEvent.VK_A:
                    offsetTargetPos(TargetOffsetDir.LEFT, offset);
                    break;
                case KeyEvent.VK_E:
                    offsetTargetPos(TargetOffsetDir.UP, offset);
                    break;
                case KeyEvent.VK_Q:
                    offsetTargetPos(TargetOffsetDir.DOWN, offset);
                    break;
            }
        }
    }
 
开发者ID:java-graphics,项目名称:java-unofficial-opengl-SDK,代码行数:53,代码来源:ViewPole.java


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