Java Code Examples for org.lwjgl.input.Keyboard#KEY_TAB

The following examples show how to use org.lwjgl.input.Keyboard#KEY_TAB . 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 File: GuiAdd.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
    switch (keyCode) {
        case Keyboard.KEY_ESCAPE:
            mc.displayGuiScreen(prevGui);
            return;
        case Keyboard.KEY_TAB:
            TabUtils.tab(username, password);
            return;
        case Keyboard.KEY_RETURN:
            actionPerformed(addButton);
            return;
    }

    if(username.isFocused())
        username.textboxKeyTyped(typedChar, keyCode);

    if(password.isFocused())
        password.textboxKeyTyped(typedChar, keyCode);
    super.keyTyped(typedChar, keyCode);
}
 
Example 2
Source File: GuiDirectLogin.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
    switch (keyCode) {
        case Keyboard.KEY_ESCAPE:
            mc.displayGuiScreen(prevGui);
            return;
        case Keyboard.KEY_TAB:
            TabUtils.tab(username, password);
            return;
        case Keyboard.KEY_RETURN:
            actionPerformed(loginButton);
            return;
    }

    if(username.isFocused())
        username.textboxKeyTyped(typedChar, keyCode);

    if(password.isFocused())
        password.textboxKeyTyped(typedChar, keyCode);
    super.keyTyped(typedChar, keyCode);
}
 
Example 3
Source File: CreateServerButton.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
    serverName.textboxKeyTyped(typedChar, keyCode);
    serverIp.textboxKeyTyped(typedChar, keyCode);
    super.keyTyped(typedChar, keyCode);

    if (keyCode == Keyboard.KEY_ESCAPE || keyCode == Keyboard.KEY_RETURN) {
        mc.displayGuiScreen(parent);
    }

    if (keyCode == Keyboard.KEY_TAB) {
        if (currentlyFocusedField == serverIp) {
            currentlyFocusedField = serverName;
            serverIp.setFocused(false);
            serverName.setFocused(true);
        } else if (currentlyFocusedField == serverName) {
            currentlyFocusedField = serverIp;
            serverName.setFocused(false);
            serverIp.setFocused(true);
        }
    }
}
 
Example 4
Source File: WidgetComboBox.java    From Signals with 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 5
Source File: GuiReactorControlRod.java    From BigReactors with 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 6
Source File: WidgetComboBox.java    From PneumaticCraft with 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 7
Source File: GuiPortScanner.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
    if(Keyboard.KEY_ESCAPE == keyCode) {
        mc.displayGuiScreen(prevGui);
        return;
    }

    if(Keyboard.KEY_TAB == keyCode)
        TabUtils.tab(hostField, minPortField, maxPortField);

    if(running)
        return;

    if(hostField.isFocused())
        hostField.textboxKeyTyped(typedChar, keyCode);

    if(minPortField.isFocused() && !Character.isLetter(typedChar))
        minPortField.textboxKeyTyped(typedChar, keyCode);

    if(maxPortField.isFocused() && !Character.isLetter(typedChar))
        maxPortField.textboxKeyTyped(typedChar, keyCode);

    if(threadsField.isFocused() && !Character.isLetter(typedChar))
        threadsField.textboxKeyTyped(typedChar, keyCode);
    super.keyTyped(typedChar, keyCode);
}
 
Example 8
Source File: Form.java    From tribaltrouble with 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 9
Source File: GuiEditNBT.java    From NBTEdit with GNU General Public License v3.0 5 votes vote down vote up
public void keyTyped(char c, int i) {
	if (i == Keyboard.KEY_ESCAPE){
		parent.closeWindow();
	}
	else if (i == Keyboard.KEY_TAB){
		if (key.isFocused() && canEditValue){
			key.setFocused(false);
			value.setFocused(true);
		}
		else if (value.isFocused() && canEditText){
			key.setFocused(true);
			value.setFocused(false);
		}
		section.setEnabled(value.isFocused());
		newLine.setEnabled(value.isFocused());
	}
	else if (i == Keyboard.KEY_RETURN) {
		checkValidInput();
		if (save.enabled)
			saveAndQuit();
	}
	else{
		key.textboxKeyTyped(c, i);
		value.textboxKeyTyped(c, i);
		checkValidInput();
	}
}
 
Example 10
Source File: ArrowButton.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public final void keyRepeat(KeyboardEvent event) {
	switch (event.getKeyCode()) {
		case Keyboard.KEY_TAB:
			super.keyRepeat(event);
			break;
	}
}
 
Example 11
Source File: Group.java    From tribaltrouble with 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 12
Source File: ScrollButton.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public final void keyRepeat(KeyboardEvent event) {
	switch (event.getKeyCode()) {
		case Keyboard.KEY_TAB:
			super.keyRepeat(event);
			break;
	}
}
 
Example 13
Source File: Menu.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
protected final void keyRepeat(KeyboardEvent event) {
	switch (event.getKeyCode()) {
		case Keyboard.KEY_TAB:
			switchFocus(event.isShiftDown() ? -1 : 1);
			break;
		case Keyboard.KEY_UP:
			focusPrior();
			break;
		case Keyboard.KEY_DOWN:
			focusNext();
			break;
		default:
			break;
	}
}
 
Example 14
Source File: GameStatsDelegate.java    From tribaltrouble with 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 15
Source File: GuiSpaceLaser.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
protected void keyTyped(char par1, int par2) throws IOException
{
	//Don't let players change the coords while the machine is running
	if(!laserTile.isRunning()) {
		if(Character.isDigit(par1) || par1 == '-' || par2 == Keyboard.KEY_BACK || par2 == Keyboard.KEY_DELETE || par2 == Keyboard.KEY_LEFT || par2 == Keyboard.KEY_RIGHT) {
			if(xbox.isFocused() && (par1 != '-' || (xbox.getCursorPosition() == 0 && !xbox.getText().startsWith("-")))) {
				xbox.textboxKeyTyped(par1, par2);

				if(!xbox.getText().isEmpty() && !xbox.getText().contentEquals("-"))
					laserTile.laserX = Integer.parseInt(xbox.getText());

				PacketHandler.sendToServer(new PacketMachine(laserTile,(byte) 0));
			}
			else if(ybox.isFocused() && (par1 != '-' || (ybox.getCursorPosition() == 0 && !ybox.getText().startsWith("-")))){
				ybox.textboxKeyTyped(par1, par2);
				if(!ybox.getText().isEmpty() && !ybox.getText().contentEquals("-"))
					laserTile.laserZ = Integer.parseInt(ybox.getText());

				PacketHandler.sendToServer(new PacketMachine(laserTile,(byte) 1));
			}
		}
	}

	if(par2 == Keyboard.KEY_TAB) {
		if(xbox.isFocused()) {
			xbox.setFocused(false);
			ybox.setFocused(true);
		}
		else if(ybox.isFocused()) {
			xbox.setFocused(true);
			ybox.setFocused(false);
		}
	}
	
	super.keyTyped(par1, par2);
}
 
Example 16
Source File: EditBox.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
protected final void keyRepeat(KeyboardEvent event) {
	//char ch = event.getKeyChar();
	Box edit_box = Skin.getSkin().getEditBox();
	switch (event.getKeyCode()) {
		case Keyboard.KEY_RETURN:
			if (insert(index, '\n')) {
				index++;
			}
			break;
		case Keyboard.KEY_BACK:
			if (index > 0)
				delete(--index);
			break;
		case Keyboard.KEY_DELETE:
			if (index < getText().length())
				delete(index);
			break;
		case Keyboard.KEY_LEFT:
			if (index > 0)
				index--;
			break;
		case Keyboard.KEY_RIGHT:
			if (index < getText().length())
				index++;
			break;
		case Keyboard.KEY_UP:
			index = getTextRenderer().jump(edit_box.getLeftOffset(),
										   edit_box.getBottomOffset(),
										   0,
										   getFont().getHeight(),
										   getText(),
										   index);
			break;
		case Keyboard.KEY_DOWN:
			index = getTextRenderer().jump(edit_box.getLeftOffset(),
										   edit_box.getBottomOffset(),
										   0,
										   -getFont().getHeight(),
										   getText(),
										   index);
			break;
		case Keyboard.KEY_HOME:
			index = getTextRenderer().jump(edit_box.getLeftOffset(),
										   edit_box.getBottomOffset(),
										   -getWidth(),
										   0,
										   getText(),
										   index);
			break;
		case Keyboard.KEY_END:
			index = getTextRenderer().jump(edit_box.getLeftOffset(),
										   edit_box.getBottomOffset(),
										   getWidth(),
										   0,
										   getText(),
										   index);
			break;
		case Keyboard.KEY_TAB:
		case Keyboard.KEY_ESCAPE:
			super.keyRepeat(event);
			break;
		default:
			char key = event.getKeyChar();
			if (getFont().getQuad(key) != null) {
				if (insert(index, key))
					index++;
			} else {
				super.keyRepeat(event);
			}
			
			break;
	}
	correctOffsetY();
}
 
Example 17
Source File: SelectionDelegate.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
public final void keyPressed(KeyboardEvent event) {
	getCamera().keyPressed(event);
	int army_number = 0;
	switch (event.getKeyCode()) {
		case Keyboard.KEY_SPACE:
		case Keyboard.KEY_NUMPAD5:
			if (!map_mode) {
				selection = false;
				getViewer().getPicker().pickRotate((GameCamera)getCamera());
				map_mode = true;
				if (observer)
					observer_label.remove();
				else
					getActionButtonPanel().remove();
				getCamera().disable();
				setCamera(new MapCamera(this, game_camera));
				getCamera().enable();
			}
			break;
		case Keyboard.KEY_TAB:
			if (!observer) {
				Notification n = getViewer().getNotificationManager().getLatestNotification();
				if (n != null) {
					if (getCamera() instanceof GameCamera)
						getGUIRoot().pushDelegate(new JumpDelegate(getViewer(), (GameCamera)getCamera(), n.getX(), n.getY()));
					else if (getCamera() instanceof MapCamera)
						((MapCamera)getCamera()).mapGoto(n.getX(), n.getY(), true);
				}
			}
			break;
		case Keyboard.KEY_9: army_number++;
		case Keyboard.KEY_8: army_number++;
		case Keyboard.KEY_7: army_number++;
		case Keyboard.KEY_6: army_number++;
		case Keyboard.KEY_5: army_number++;
		case Keyboard.KEY_4: army_number++;
		case Keyboard.KEY_3: army_number++;
		case Keyboard.KEY_2: army_number++;
		case Keyboard.KEY_1: army_number++;
		case Keyboard.KEY_0:
			if (!map_mode && !observer) {
				if (event.isControlDown()) {
					getViewer().getSelection().setShortcutArmy(army_number);
				} else {
					boolean selected = getViewer().getSelection().enableShortcutArmy(army_number);
					if (selected && event.getNumClicks() > 1) {
						Set set = getViewer().getSelection().getCurrentSelection().getSet();
						if (set.size() > 0) {
							Selectable s = (Selectable)set.iterator().next();
							getGUIRoot().pushDelegate(new JumpDelegate(getViewer(), (GameCamera)getCamera(), s.getPositionX(), s.getPositionY()));
						}
					}
				}
			}
			break;
		case Keyboard.KEY_RETURN:
				if (!chat_visible)
					chat_form.setReceivers(!event.isShiftDown());
			break;
		case Keyboard.KEY_B:
			if (event.isControlDown() && !map_mode && !observer) {
				getGUIRoot().pushDelegate(new BeaconDelegate(getViewer(), (GameCamera)getCamera()));
			}
			break;
		case Keyboard.KEY_N:
			nextIdlePeon();
			break;
		case Keyboard.KEY_F:
		case Keyboard.KEY_Z:
			if (!map_mode)
				super.keyPressed(event);
			break;
		default:
			if (map_mode || observer) {
				super.keyPressed(event);
			} else {
				if (!getActionButtonPanel().doKeyPressed(event))
					super.keyPressed(event);
			}
			break;
	}
}
 
Example 18
Source File: GuiReactorRedstonePort.java    From BigReactors with MIT License 4 votes vote down vote up
@Override
protected void keyTyped(char inputChar, int keyCode) {
	boolean isAnyTextboxFocused = this.subInputRodSetting.isFocused() ||
									this.subInputRodSettingOff.isFocused() ||
									this.subOutputValue.isFocused();
	
       if (keyCode == Keyboard.KEY_ESCAPE ||
       		(!isAnyTextboxFocused && keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode())) {
           this.mc.thePlayer.closeScreen();
       }

       // Allow arrow keys, 0-9, and delete
       if(isKeyValidForValueInput(keyCode)) {
           if(this.subInputRodSetting.isFocused()) {
           	this.subInputRodSetting.textboxKeyTyped(inputChar,  keyCode);
               validateInputValues();
           }
           if(this.subInputRodSettingOff.isFocused()) {
           	this.subInputRodSettingOff.textboxKeyTyped(inputChar,  keyCode);
               validateInputValues();
           }
           if(this.subOutputValue.isFocused()) {
           	this.subOutputValue.textboxKeyTyped(inputChar,  keyCode);
           	validateOutputValues();
           }
           
       }
	
	if(keyCode == Keyboard.KEY_TAB) {
		/// ffffffuuuuuuuck tabbing
		if(this.subOutputValue.isFocused()) {
			this.subOutputValue.setFocused(false);
		}
		else if(this.subOutputValue.getVisible()) {
			this.subOutputValue.setFocused(true);
		}
		
		if(this.subInputRodSettingOff.getVisible()) {
			if(this.subInputRodSetting.isFocused()) {
				this.subInputRodSetting.setFocused(false);
				this.subInputRodSettingOff.setFocused(true);
			}
			else if(this.subInputRodSettingOff.isFocused()) {
				this.subInputRodSettingOff.setFocused(false);
			}
			else {
				this.subInputRodSetting.setFocused(true);
			}
		}
		else if(this.subInputRodSetting.getVisible()) {
			if(this.subInputRodSetting.isFocused()) {
				this.subInputRodSetting.setFocused(false);
			}
			else {
				this.subInputRodSetting.setFocused(true);
			}
		}
		// Else, nothing is visible, nothing is focused, screw you.
	}
	
	if(keyCode == Keyboard.KEY_RETURN && isAnyTextboxFocused) {
		this.subInputRodSetting.setFocused(false);
		this.subInputRodSettingOff.setFocused(false);
		this.subOutputValue.setFocused(false);
	}
}