org.lwjgl.input.Keyboard Java Examples

The following examples show how to use org.lwjgl.input.Keyboard. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: I18nUpdateMod   Author: CFPAOrg   File: HotKeyHandler.java    License: MIT License 6 votes vote down vote up
/**
 * 获取输入按键,进行不同处理
 *
 * @param stack 物品
 * @return 是否成功
 */
private boolean handleKey(ItemStack stack) {
    if (stack != null && stack != ItemStack.EMPTY && stack.getItem() != Items.AIR) {
        // 问题报告界面的打开
        if (keyCodeCheck(reportKey.getKeyCode()) && Keyboard.isKeyDown(mainKey.getKeyCode()) && Keyboard.getEventKey() == reportKey.getKeyCode()) {
            return openReport(stack);
        }
        // Weblate 翻译界面的打开
        else if (keyCodeCheck(weblateKey.getKeyCode()) && Keyboard.isKeyDown(mainKey.getKeyCode()) && Keyboard.getEventKey() == weblateKey.getKeyCode()) {
            return openWeblate(stack);
        }
        // mcmod 百科界面的打开
        else if (keyCodeCheck(mcmodKey.getKeyCode()) && Keyboard.isKeyDown(mainKey.getKeyCode()) && Keyboard.getEventKey() == mcmodKey.getKeyCode()) {
            return openMcmod(stack);
        }
    }
    return false;
}
 
Example #2
Source Project: FEMultiPlayer-V2   Author: eliatlarge   File: FEResources.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets the key mapped name.
 *
 * @param internalKeyName the internal key name
 * @return the key mapped name
 */
public static String getKeyMappedName(String internalKeyName){
	if(internalKeyName.toUpperCase().equals("ENTER")){
		internalKeyName = "RETURN";
	}
	int key = Keyboard.getKeyIndex(internalKeyName.toUpperCase());
	int mappedKey = getKeyMapped(key);
	String mappedName = Keyboard.getKeyName(mappedKey);
	//this might seem redundant, but it's to allow code using the string "Enter" to map to the key "Return"
	//which then maps the key according to the bindings (possibly to something else)
	//if it's still "return" we want this translated back to "enter"
	if(mappedName.equals("RETURN")){
		return "ENTER";
	}
	return mappedName;
}
 
Example #3
Source Project: Wizardry   Author: TeamWizardry   File: ItemFairyBell.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void onScroll(MouseEvent event) {
	EntityPlayer player = Minecraft.getMinecraft().player;
	if (player == null) return;

	if (Keyboard.isCreated() && event.getDwheel() != 0) {

		for (EnumHand hand : EnumHand.values()) {
			ItemStack stack = player.getHeldItem(hand);

			if (stack.getItem() != ModItems.FAIRY_BELL)
				continue;


			IMiscCapability cap = MiscCapabilityProvider.getCap(Minecraft.getMinecraft().player);
			if (cap == null) continue;

			cap.setSelectedFairy(null);

			PacketHandler.NETWORK.sendToServer(new PacketUpdateMiscCapToServer(cap.serializeNBT()));
		}
	}
}
 
Example #4
Source Project: BigReactors   Author: erogenousbeef-zz   File: GuiReactorControlRod.java    License: MIT License 6 votes vote down vote up
@Override
protected void keyTyped(char inputChar, int keyCode) {
       if (keyCode == Keyboard.KEY_ESCAPE ||
       		(!this.rodName.isFocused() && keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode())) {
           this.mc.thePlayer.closeScreen();
       }

	this.rodName.textboxKeyTyped(inputChar, keyCode);
	
	if(keyCode == Keyboard.KEY_TAB) {
		// Tab
		if(this.rodName.isFocused()) {
			this.rodName.setFocused(false);
		}
		else {
			this.rodName.setFocused(true);
		}
	}
	
	if(keyCode == Keyboard.KEY_RETURN) {
		// Return/enter
		this.actionPerformed((GuiButton)this.buttonList.get(2));
	}
}
 
Example #5
Source Project: Slyther   Author: gegy1000   File: TextBoxElement.java    License: MIT License 6 votes vote down vote up
@Override
public void keyPressed(int key, char character) {
    if (selected) {
        boolean modified = false;
        if (key == Keyboard.KEY_BACK) {
            if (text.length() > 0 && selectionIndex > 0) {
                text = text.substring(0, Math.max(0, selectionIndex - 1)) + text.substring(selectionIndex);
                selectionIndex--;
                modified = true;
            }
        } else if (character != 167 && character >= 32 && character != 127) {
            text = text.substring(0, selectionIndex) + character + text.substring(selectionIndex);
            selectionIndex++;
            modified = true;
        } else if (key == Keyboard.KEY_LEFT && selectionIndex > 0) {
            selectionIndex--;
        } else if (key == Keyboard.KEY_RIGHT && selectionIndex < text.length()) {
            selectionIndex++;
        }
        if (modified) {
            function.apply(this);
        }
    }
}
 
Example #6
Source Project: I18nUpdateMod   Author: CFPAOrg   File: HotKeyHandler.java    License: MIT License 6 votes vote down vote up
@SubscribeEvent
public void onKeyPressNoGui(InputEvent.KeyInputEvent e) {
    // 最开始,检测是否启用国际化配置
    if (I18nConfig.internationalization.openI18n && !I18nUtils.isChinese()) {
        return;
    }

    // 接下来检测是否关闭键位
    if (I18nConfig.key.closedKey) {
        return;
    }

    // 取消重复显示
    if (showed) {
        if (keyCodeCheck(reloadKey.getKeyCode()) && !Keyboard.isKeyDown(reloadKey.getKeyCode())) {
            showed = false;
        }
        return;
    }
    showed = reloadLocalization();
}
 
Example #7
Source Project: opsu-dance   Author: yugecin   File: ComplexOpsuState.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void keyPressed(KeyEvent e)
{
	for (OverlayOpsuState overlay : overlays) {
		overlay.keyPressed(e);
		if (e.isConsumed()) {
			return;
		}
	}
	if (focusedComponent != null) {
		if (e.keyCode == Keyboard.KEY_ESCAPE) {
			focusedComponent.setFocused(false);
			focusedComponent = null;
		} else {
			focusedComponent.keyPressed(e);
		}
		e.consume();
	}
}
 
Example #8
Source Project: LWJGL-OpenGL-Tutorials   Author: ra4king   File: Example10_2.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void update(long deltaTime) {
	Utils.updateMousePoles(viewPole, objectPole);
	
	lightTimer.update(deltaTime);
	
	float speed = (deltaTime / (float)1e9) * (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) ? 0.5f : 2f);
	
	if(Keyboard.isKeyDown(Keyboard.KEY_I))
		lightHeight += speed;
	if(Keyboard.isKeyDown(Keyboard.KEY_K))
		lightHeight -= speed;
	if(Keyboard.isKeyDown(Keyboard.KEY_L))
		lightRadius += speed;
	if(Keyboard.isKeyDown(Keyboard.KEY_J))
		lightRadius -= speed;
	
	if(lightRadius < 0.2f)
		lightRadius = 0.2f;
}
 
Example #9
Source Project: FEMultiplayer   Author: chudooder   File: LobbyChatBox.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void beginStep() {
	List<MouseEvent> mouseEvents = Game.getMouseEvents();
	for(MouseEvent event : mouseEvents) {
		if(event.button == 0) {
			if(inBounds(event.x, Game.getWindowHeight()-event.y)) {
				hasFocus = true;
			} else {
				hasFocus = false;
			}
		}
	}
	super.beginStep();
	if(hasFocus) {
		List<KeyboardEvent> keys = Game.getKeys();
		for(KeyboardEvent ke : keys) {
			if(ke.state) {
				if(ke.key == Keyboard.KEY_RETURN) { 
					send();
				}
			}
		}
	}
}
 
Example #10
Source Project: ehacks-pro   Author: radioegor146   File: SimpleWindow.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void windowDragged(int x, int y) {
    if (!dragging) {
        return;
    }
    this.xPos = this.prevXPos + (x - this.dragX);
    this.yPos = this.prevYPos + (y - this.dragY);
    ScaledResolution res = new ScaledResolution(Wrapper.INSTANCE.mc(), Wrapper.INSTANCE.mc().displayWidth, Wrapper.INSTANCE.mc().displayHeight);
    if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
        if (this.xPos < 20) {
            this.xPos = 2;
        }
        if (this.yPos < 20) {
            this.yPos = 2;
        }
        if (this.xPos + this.width > res.getScaledWidth() - 20) {
            this.xPos = res.getScaledWidth() - this.width - 2;
        }
        if (this.yPos + this.height > res.getScaledHeight() - 20) {
            this.yPos = res.getScaledHeight() - this.height - 2;
        }
    }
}
 
Example #11
Source Project: ehacks-pro   Author: radioegor146   File: CreativeGive.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onTicks() {
    boolean newState = Keyboard.isKeyDown(GiveKeybind.getKey());
    if (newState && !prevState) {
        prevState = newState;
        int slotId = 36 + Wrapper.INSTANCE.player().inventory.currentItem;
        if (Statics.STATIC_ITEMSTACK == null) {
            return;
        }
        if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
            for (int i = 9; i < 45; i++) {
                setCreative(Statics.STATIC_ITEMSTACK, i);
            }
        } else {
            setCreative(Statics.STATIC_ITEMSTACK, slotId);
        }
        InteropUtils.log("Set", this);
    }
    prevState = newState;
}
 
Example #12
Source Project: Signals   Author: MineMaarten   File: WidgetComboBox.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onKey(char key, int keyCode){
    if(fixedOptions) return false;
    if(enabled && isFocused() && keyCode == Keyboard.KEY_TAB) {//Auto-complete
        List<String> applicableElements = getApplicableElements();
        if(applicableElements.size() > 0) {
            setText(applicableElements.get(0));
            listener.onKeyTyped(this);
            return true;
        } else {
            return super.onKey(key, keyCode);
        }
    } else {
        return super.onKey(key, keyCode);
    }
}
 
Example #13
Source Project: ClientBase   Author: superblaubeere27   File: KeybindButton.java    License: MIT License 6 votes vote down vote up
@Override
public boolean keyPressed(int key, char c) {
    if (listening) {
        listening = false;

        if (Keyboard.getEventKey() != 256 && Keyboard.getEventCharacter() != 0) {
            int newValue = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey();


            if (listener != null)
                if (listener.onValueChange(newValue))
                    this.value = newValue;
        }

        updateState();
    }

    return super.keyPressed(key, c);
}
 
Example #14
Source Project: tribaltrouble   Author: sunenielsen   File: KeyboardInput.java    License: GNU General Public License v2.0 5 votes vote down vote up
public final boolean doPoll(GUIRoot gui_root) {
	Deterministic deterministic = LocalEventQueue.getQueue().getDeterministic();
	LocalInput local_input = LocalInput.getLocalInput();
	boolean result = false;
	Keyboard.poll();
	while (deterministic.log(Keyboard.next())) {
		result = true;
		int event_key = deterministic.log(Keyboard.getEventKey());
		boolean event_key_state = deterministic.log(Keyboard.getEventKeyState());
		char event_character = deterministic.log(Keyboard.getEventCharacter());
		boolean repeat_event = deterministic.log(Keyboard.isRepeatEvent());
		switch (event_key) {
			case Keyboard.KEY_LSHIFT:
			case Keyboard.KEY_RSHIFT:
				shift_down = event_key_state;
				break;
			case Keyboard.KEY_LCONTROL:
			case Keyboard.KEY_RCONTROL:
				control_down = event_key_state;
				break;
			case Keyboard.KEY_LMENU:
			case Keyboard.KEY_RMENU:
				menu_down = event_key_state;
				break;
		}
		if (checkMagicKey(deterministic, event_key_state, event_key, false, repeat_event))
			continue;
		if (event_key == Keyboard.KEY_NONE) {
			local_input.keyTyped(gui_root, event_key, event_character);
		} else if (event_key_state) {
			local_input.keyPressed(gui_root, event_key, event_character, shift_down, control_down, menu_down, repeat_event);
		} else {
			local_input.keyReleased(gui_root, event_key, event_character, shift_down, control_down, menu_down);
		}
	}
	return result;
}
 
Example #15
Source Project: tribaltrouble   Author: sunenielsen   File: Form.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected void keyRepeat(KeyboardEvent event) {
	switch (event.getKeyCode()) {
		case Keyboard.KEY_TAB:
			super.keyRepeat(event);
			break;
		case Keyboard.KEY_ESCAPE:
			cancel();
			break;
		default:
			break;
	}
}
 
Example #16
Source Project: ForgeWurst   Author: Wurst-Imperium   File: BindsCmd.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void add(String[] args) throws CmdException
{
	if(args.length < 3)
		throw new CmdSyntaxError();
	
	String key = args[1].toUpperCase();
	if(Keyboard.getKeyIndex(key) == Keyboard.KEY_NONE)
		throw new CmdSyntaxError("Unknown key: " + key);
	
	String commands =
		String.join(" ", Arrays.copyOfRange(args, 2, args.length));
	
	wurst.getKeybinds().add(key, commands);
	ChatUtils.message("Keybind set: " + key + " -> " + commands);
}
 
Example #17
Source Project: NotEnoughItems   Author: Chicken-Bones   File: SaveLoadButton.java    License: MIT License 5 votes vote down vote up
@Override
public boolean handleKeyPress(int keyID, char keyChar)
{
    if(!focused)
        return false;
    
    if(keyID == Keyboard.KEY_BACK)
    {
        if(label.length() > 0)
        {
            label = label.substring(0, label.length() - 1);
            onTextChange();
            backdowntime = System.currentTimeMillis();
        }
    }
    else if(keyID == Keyboard.KEY_RETURN)
    {
        focused = false;
    }        
    else if(keyChar == 22)//paste
    {
        String pastestring = GuiScreen.getClipboardString();
        if(pastestring == null) 
            pastestring = "";

        label = label + pastestring;
        onTextChange();
    }
    else if(ChatAllowedCharacters.isAllowedCharacter(keyChar))
    {
        label = label + keyChar;
        onTextChange();
    }
    return true;
}
 
Example #18
Source Project: ehacks-pro   Author: radioegor146   File: Magnendo.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onTicks() {
    if (Keyboard.isKeyDown(MagnetKeybind.getKey()) && !prevState) {
        int cnt = 0;
        for (Object entObj : Wrapper.INSTANCE.world().loadedEntityList) {
            Entity ent = (Entity) entObj;
            if (ent instanceof EntityItem) {
                cnt++;
                tpEntity(ent, (int) Math.round(Wrapper.INSTANCE.player().lastTickPosX), (int) Math.round(Wrapper.INSTANCE.player().lastTickPosY), (int) Math.round(Wrapper.INSTANCE.player().lastTickPosZ));
            }
        }
        InteropUtils.log("Magneted " + cnt + " items", this);
    }
    prevState = Keyboard.isKeyDown(MagnetKeybind.getKey());
}
 
Example #19
Source Project: tribaltrouble   Author: sunenielsen   File: EditLine.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected void keyReleased(KeyboardEvent event) {
	switch (event.getKeyCode()) {
		case Keyboard.KEY_RETURN:
			enterPressedAll();
			break;
		default:
			super.keyReleased(event);
			break;
	}
}
 
Example #20
Source Project: LWJGL-OpenGL-Tutorials   Author: ra4king   File: Example16_2.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void keyPressed(int key, char c) {
	switch(key) {
		case Keyboard.KEY_SPACE:
			drawGammaProgram = !drawGammaProgram;
			drawGammaTexture = !drawGammaTexture;
			break;
		case Keyboard.KEY_A:
			drawGammaProgram = !drawGammaProgram;
			break;
		case Keyboard.KEY_G:
			drawGammaTexture = !drawGammaTexture;
			break;
		case Keyboard.KEY_Y:
			drawCorridor = !drawCorridor;
			break;
		case Keyboard.KEY_P:
			camTimer.togglePause();
			break;
	}
	
	System.out.println("----");
	System.out.printf("Rendering:\t\t%s\n", drawGammaProgram ? "Gamma" : "Linear");
	System.out.printf("Mipmap Generation:\t%s\n", drawGammaTexture ? "Gamma" : "Linear");
	
	if(c >= '1' && c <= '9') {
		int number = c - '1';
		if(number < NUM_SAMPLERS)
			currSampler = number;
	}
}
 
Example #21
Source Project: tribaltrouble   Author: sunenielsen   File: FirstPersonCamera.java    License: GNU General Public License v2.0 5 votes vote down vote up
public final void doAnimate(float t) {
	float dir_x = (float)StrictMath.cos(getState().getTargetHorizAngle());
	float dir_y = (float)StrictMath.sin(getState().getTargetHorizAngle());
	float left_dir_x = -dir_y;
	float left_dir_y = dir_x;

	float scrolling_x = 0;
	float scrolling_y = 0;
	if (LocalInput.isKeyDown(Keyboard.KEY_LEFT) && !LocalInput.isKeyDown(Keyboard.KEY_RIGHT))
		scrolling_x = -1f;
	else if (LocalInput.isKeyDown(Keyboard.KEY_RIGHT) && !LocalInput.isKeyDown(Keyboard.KEY_LEFT))
		scrolling_x = 1f;

	if (LocalInput.isKeyDown(Keyboard.KEY_DOWN) && !LocalInput.isKeyDown(Keyboard.KEY_UP))
		scrolling_y = -1f;
	else if (LocalInput.isKeyDown(Keyboard.KEY_UP) && !LocalInput.isKeyDown(Keyboard.KEY_DOWN))
		scrolling_y = 1f;

	float scroll_factor = getState().getTargetZ()*t;
	float new_x = getState().getTargetX() - (scrolling_x*left_dir_x + scrolling_y*-left_dir_y)*scroll_factor;
	float new_y = getState().getTargetY() - (scrolling_x*left_dir_y + scrolling_y*left_dir_x)*scroll_factor;

	if (new_x != getState().getTargetX() || new_y != getState().getTargetY()) {
		getState().setTargetX(new_x);
		getState().setTargetY(new_y);
		checkPosition();
	}
}
 
Example #22
Source Project: tribaltrouble   Author: sunenielsen   File: Group.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected void keyRepeat(KeyboardEvent event) {
	switch (event.getKeyCode()) {
		case Keyboard.KEY_TAB:
			switchFocus(event.isShiftDown() ? -1 : 1);
			break;
		default:
			super.keyRepeat(event);
			break;
	}
}
 
Example #23
Source Project: SimplyJetpacks   Author: Tonius   File: KeyHandler.java    License: MIT License 5 votes vote down vote up
private static void tickStart() {
    if (mc.thePlayer != null) {
        boolean flyState;
        boolean descendState;
        if (Config.customControls) {
            flyState = mc.inGameHasFocus && Keyboard.isKeyDown(flyKey);
            descendState = mc.inGameHasFocus && Keyboard.isKeyDown(descendKey);
        } else {
            flyState = mc.gameSettings.keyBindJump.getIsKeyPressed();
            descendState = mc.gameSettings.keyBindSneak.getIsKeyPressed();
        }
        
        boolean forwardState = mc.gameSettings.keyBindForward.getIsKeyPressed();
        boolean backwardState = mc.gameSettings.keyBindBack.getIsKeyPressed();
        boolean leftState = mc.gameSettings.keyBindLeft.getIsKeyPressed();
        boolean rightState = mc.gameSettings.keyBindRight.getIsKeyPressed();
        
        if (flyState != lastFlyState || descendState != lastDescendState || forwardState != lastForwardState || backwardState != lastBackwardState || leftState != lastLeftState || rightState != lastRightState) {
            lastFlyState = flyState;
            lastDescendState = descendState;
            
            lastForwardState = forwardState;
            lastBackwardState = backwardState;
            lastLeftState = leftState;
            lastRightState = rightState;
            PacketHandler.instance.sendToServer(new MessageKeyboardSync(flyState, descendState, forwardState, backwardState, leftState, rightState));
            SyncHandler.processKeyUpdate(mc.thePlayer, flyState, descendState, forwardState, backwardState, leftState, rightState);
        }
    }
}
 
Example #24
Source Project: mapwriter   Author: daveyliam   File: MwGui.java    License: MIT License 5 votes vote down vote up
public void exitGui() {
	//MwUtil.log("closing GUI");
	// set the mini map dimension to the GUI map dimension when closing
	this.mw.miniMap.view.setDimension(this.mapView.getDimension());
	this.mapMode.close();
	Keyboard.enableRepeatEvents(false);
	this.mc.displayGuiScreen((GuiScreen) null);
    this.mc.setIngameFocus();
    this.mc.getSoundHandler().resumeSounds();
}
 
Example #25
Source Project: tribaltrouble   Author: sunenielsen   File: KeyboardInput.java    License: GNU General Public License v2.0 5 votes vote down vote up
public final void doCheckMagicKeys() {
	Deterministic deterministic = LocalEventQueue.getQueue().getDeterministic();
	if (deterministic.isPlayback()) {
		Keyboard.poll();
		while (Keyboard.next()) {
			int event_key = Keyboard.getEventKey();
			boolean event_key_state = Keyboard.getEventKeyState();
			checkMagicKey(deterministic, event_key_state, event_key, true, Keyboard.isRepeatEvent());
		}
	}
}
 
Example #26
Source Project: ehacks-pro   Author: radioegor146   File: VerticalGui.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onTicks() {
    boolean newState = Keyboard.isKeyDown(Keyboard.KEY_Y);
    if (newState && !prevState) {
        openGui();
    }
    prevState = newState;
}
 
Example #27
Source Project: The-5zig-Mod   Author: 5zig   File: Variables.java    License: MIT License 5 votes vote down vote up
@Override
public void dispatchKeypresses() {
	int eventKey = org.lwjgl.input.Keyboard.getEventKey();
	int currentcode = eventKey == 0 ? org.lwjgl.input.Keyboard.getEventCharacter() : eventKey;
	if ((currentcode == 0) || (org.lwjgl.input.Keyboard.isRepeatEvent()))
		return;

	if (org.lwjgl.input.Keyboard.getEventKeyState()) {
		int keyCode = currentcode + (eventKey == 0 ? 256 : 0);
		MinecraftFactory.getClassProxyCallback().fireKeyPressEvent(keyCode);
	}
}
 
Example #28
Source Project: tectonicus   Author: tectonicus   File: LwjglRasteriser.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public boolean isKeyDown(final int vkKey)
{
	if (!keyCodeMap.containsKey(vkKey))
		throw new RuntimeException("No mapping for :"+vkKey);
	
	Integer lwjglKey = keyCodeMap.get(vkKey);
	return Keyboard.isKeyDown(lwjglKey);
}
 
Example #29
Source Project: NOVA-Core   Author: NOVA-Team   File: MCInputManager.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void mapKeys() {
	// Map jlwgl input to NOVA Keys, slightly hacky but functional.
	for (Key key : Key.values()) {
		try {
			keys.put(Keyboard.class.getDeclaredField(key.name()).getInt(null), key);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
Example #30
Source Project: NotEnoughItems   Author: TheCBProject   File: SaveLoadButton.java    License: MIT License 5 votes vote down vote up
@Override
public boolean handleKeyPress(int keyID, char keyChar) {
    if (!focused) {
        return false;
    }

    if (keyID == Keyboard.KEY_BACK) {
        if (label.length() > 0) {
            label = label.substring(0, label.length() - 1);
            onTextChange();
            backdowntime = System.currentTimeMillis();
        }
    } else if (keyID == Keyboard.KEY_RETURN) {
        focused = false;
    } else if (keyChar == 22)//paste
    {
        String pastestring = GuiScreen.getClipboardString();
        if (pastestring == null) {
            pastestring = "";
        }

        label = label + pastestring;
        onTextChange();
    } else if (ChatAllowedCharacters.isAllowedCharacter(keyChar)) {
        label = label + keyChar;
        onTextChange();
    }
    return true;
}