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

The following examples show how to use org.lwjgl.input.Keyboard#KEY_RETURN . 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: TeamNameInput.java    From FEMultiplayer with GNU General Public License v3.0 6 votes vote down vote up
public void beginStep(){
	super.beginStep();
	List<KeyboardEvent> keys = Game.getKeys();
	for(KeyboardEvent ke : keys) {
		if(ke.state) {
			if(ke.key == Keyboard.KEY_RETURN) { 
				if(!new File("teams").exists()){
					new File("teams").mkdir();
				}
				if(save){
					save();
				} else {
					load();
				}
				destroy();
				((TeamBuilderStage) stage).setControl(true);
				
			}
		}
	}
}
 
Example 2
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 3
Source File: SelectionDelegate.java    From tribaltrouble with GNU General Public License v2.0 6 votes vote down vote up
public final void keyReleased(KeyboardEvent event) {
	getCamera().keyReleased(event);
	switch (event.getKeyCode()) {
		case Keyboard.KEY_RETURN:
			if (!close_chat_override) {
				if (!chat_visible) {
					addChild(chat_form);
					chat_form.setPos(GameCamera.SCROLL_BUFFER, GameCamera.SCROLL_BUFFER);
					chat_form.setFocus();
					chat_visible = true;
				}
			} else {
				close_chat_override = false;
			}
			break;
		default:
			if (!map_mode && !observer && !getActionButtonPanel().doKeyReleased(event))
				super.keyReleased(event);
			break;
	}
}
 
Example 4
Source File: GuiEditNBTTree.java    From NBTEdit with GNU General Public License v3.0 6 votes vote down vote up
protected void keyTyped(char par1, int key) {
	GuiEditNBT window = guiTree.getWindow();
	if (window != null)
		window.keyTyped(par1, key);
	else{
		if (key == 1){
			if (guiTree.isEditingSlot())
				guiTree.stopEditingSlot();
			else
				quitWithoutSaving();
		}
		else if (key == Keyboard.KEY_DELETE)
			guiTree.deleteSelected();
		else if (key == Keyboard.KEY_RETURN)
			guiTree.editSelected();
		else if (key == Keyboard.KEY_UP)
			guiTree.arrowKeyPressed(true);
		else if (key == Keyboard.KEY_DOWN)
			guiTree.arrowKeyPressed(false);
		else
			guiTree.keyTyped(par1, key);
	}
}
 
Example 5
Source File: MwGuiTextDialog.java    From mapwriter with MIT License 6 votes vote down vote up
protected void keyTyped(char c, int key) {
  	switch (key) {
case Keyboard.KEY_ESCAPE:
	this.mc.displayGuiScreen(this.parentScreen);
	break;
	
case Keyboard.KEY_RETURN:
	// when enter pressed, submit current input
	if (this.submit()) {
		if (!this.backToGameOnSubmit) {
			this.mc.displayGuiScreen(this.parentScreen);
		} else {
			this.mc.displayGuiScreen(null);
		}
	}
	break;
	
default:
	// other characters are processed by the text box
	this.textField.textboxKeyTyped(c, key);
	this.text = this.textField.getText();
  		break;
}
  }
 
Example 6
Source File: GuiSchematicSaveBase.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean onKeyTyped(char typedChar, int keyCode)
{
    if (this.textField.isFocused() && keyCode == Keyboard.KEY_RETURN)
    {
        this.saveSchematic();
        return true;
    }
    else if (this.textField.onKeyTyped(typedChar, keyCode))
    {
        this.getListWidget().clearSelection();
        return true;
    }

    return super.onKeyTyped(typedChar, keyCode);
}
 
Example 7
Source File: GuiScrollSlot.java    From CodeChickenCore with MIT License 5 votes vote down vote up
@Override
public void keyTyped(char c, int keycode) {
    if (!focused)
        return;

    if (keycode == Keyboard.KEY_UP)
        selectPrev();
    if (keycode == Keyboard.KEY_DOWN)
        selectNext();
    if (keycode == Keyboard.KEY_RETURN && actionCommand != null)
        sendAction(actionCommand);
}
 
Example 8
Source File: EditLine.java    From tribaltrouble with 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 9
Source File: TargetDelegate.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public final void keyPressed(KeyboardEvent event) {
	getCamera().keyPressed(event);
	switch (event.getKeyCode()) {
		case Keyboard.KEY_ESCAPE:
			pop();
			break;
		case Keyboard.KEY_SPACE:
		case Keyboard.KEY_RETURN:
			break;
		default:
			super.keyPressed(event);
			break;
	}
}
 
Example 10
Source File: GuiTextInput.java    From ForgeHax with MIT License 5 votes vote down vote up
public void keyTyped(char typedChar, int keyCode) throws IOException {
  if (isActive) {
    switch (keyCode) {
      case Keyboard.KEY_ESCAPE:
        isActive = false;
        break;
      
      case Keyboard.KEY_RETURN:
        isActive = false;
        // setValue(input);
        MC.player.sendMessage(new TextComponentString(input.toString()));
        break;
      
      case Keyboard.KEY_BACK:
        if (selectedIndex > -1) {
          input.deleteCharAt(selectedIndex);
          selectedIndex--;
        }
        break;
      
      case Keyboard.KEY_LEFT:
        selectedIndex--;
        break;
      
      case Keyboard.KEY_RIGHT:
        selectedIndex++;
        break;
      
      default:
        if (isValidChar(typedChar)) {
          selectedIndex++;
          input.insert(selectedIndex, typedChar);
        }
    }
    selectedIndex = MathHelper.clamp(selectedIndex, -1, input.length() - 1);
  }
}
 
Example 11
Source File: EditSliderScreen.java    From ForgeWurst with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
	valueField.textboxKeyTyped(typedChar, keyCode);
	
	if(keyCode == Keyboard.KEY_RETURN)
		actionPerformed(doneButton);
	else if(keyCode == Keyboard.KEY_ESCAPE)
		mc.displayGuiScreen(prevScreen);
}
 
Example 12
Source File: EditBlockListScreen.java    From ForgeWurst with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
	blockNameField.textboxKeyTyped(typedChar, keyCode);
	
	if(keyCode == Keyboard.KEY_RETURN)
		actionPerformed(addButton);
	else if(keyCode == Keyboard.KEY_DELETE)
		actionPerformed(removeButton);
	else if(keyCode == Keyboard.KEY_ESCAPE)
		actionPerformed(doneButton);
}
 
Example 13
Source File: ArrowButton.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public final void keyReleased(KeyboardEvent event) {
	switch (event.getKeyCode()) {
		case Keyboard.KEY_SPACE:
		case Keyboard.KEY_RETURN:
			mouseReleasedAll(LocalInput.LEFT_BUTTON, 0, 0);
			break;
	}
}
 
Example 14
Source File: TabGui.java    From ClientBase with MIT License 5 votes vote down vote up
public void handleKey(int keycode) {
    if (keycode == Keyboard.KEY_DOWN) {
        if (selectedSubTab == -1) {
            selectedTab++;

            if (selectedTab >= tabs.size()) {
                selectedTab = 0;
            }
        } else {
            selectedSubTab++;

            if (selectedSubTab >= tabs.get(selectedTab).getSubTabs().size()) {
                selectedSubTab = 0;
            }
        }
    } else if (keycode == Keyboard.KEY_UP) {
        if (selectedSubTab == -1) {
            selectedTab--;

            if (selectedTab < 0) {
                selectedTab = tabs.size() - 1;
            }
        } else {
            selectedSubTab--;

            if (selectedSubTab < 0) {
                selectedSubTab = tabs.get(selectedTab).getSubTabs().size() - 1;
            }
        }
    } else if (keycode == Keyboard.KEY_LEFT) {
        selectedSubTab = -1;
    } else if (selectedSubTab == -1 && (keycode == Keyboard.KEY_RETURN || keycode == Keyboard.KEY_RIGHT)) {
        selectedSubTab = 0;
    } else if (keycode == Keyboard.KEY_RETURN || keycode == Keyboard.KEY_RIGHT) {
        tabs.get(selectedTab).getSubTabs().get(selectedSubTab).press();
    }
}
 
Example 15
Source File: GUIObject.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
protected void keyPressed(KeyboardEvent event) {
	if (event.getKeyCode() == Keyboard.KEY_SPACE || event.getKeyCode() == Keyboard.KEY_RETURN) {
		mousePressedAll(LocalInput.LEFT_BUTTON, 0, 0);
	} else {
		GUIObject parent = (GUIObject)getParent();
		if (parent != null)
			parent.keyPressedAll(event);
	}
}
 
Example 16
Source File: GuiCCTextField.java    From CodeChickenCore with MIT License 5 votes vote down vote up
@Override
public void keyTyped(char c, int keycode)
{
    if(!isEnabled || !isFocused)
        return;

    /*if(c == '\t')//tab
    {
        parentGuiScreen.selectNextField();
    }*/
    if(c == '\026')//paste
    {
        String s = GuiScreen.getClipboardString();
        if(s == null || s.equals(""))
            return;

        for(int i = 0; i < s.length(); i++)
        {
            if(text.length() == maxStringLength)
                return;

            char tc = s.charAt(i);
            if(canAddChar(tc))
                setText(text + tc);
        }
    }
    if(keycode == Keyboard.KEY_RETURN)
    {
        setFocused(false);
        sendAction(actionCommand, getText());
    }

    if(keycode == Keyboard.KEY_BACK && text.length() > 0)
        setText(text.substring(0, text.length() - 1));

    if((text.length() < maxStringLength || maxStringLength == 0) && canAddChar(c))
        setText(text + c);
}
 
Example 17
Source File: TextField.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
protected final void keyPressed(KeyboardEvent event) {
	if (event.getKeyCode() != Keyboard.KEY_SPACE && event.getKeyCode() != Keyboard.KEY_RETURN)
		super.keyPressed(event);
}
 
Example 18
Source File: TextField.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
protected void keyReleased(KeyboardEvent event) {
	if (event.getKeyCode() != Keyboard.KEY_SPACE && event.getKeyCode() != Keyboard.KEY_RETURN)
		super.keyReleased(event);
}
 
Example 19
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 20
Source File: TargetDelegate.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
public void keyReleased(KeyboardEvent event) {
	if (event.getKeyCode() != Keyboard.KEY_SPACE || event.getKeyCode() != Keyboard.KEY_RETURN)
		getCamera().keyReleased(event);
}