本文整理了Java中org.lwjgl.input.Mouse.getEventButtonState()
方法的一些代码示例,展示了Mouse.getEventButtonState()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mouse.getEventButtonState()
方法的具体详情如下:
包路径:org.lwjgl.input.Mouse
类名称:Mouse
方法名:getEventButtonState
暂无
代码示例来源:origin: MovingBlocks/Terasology
@Override
public Queue<MouseAction> getInputQueue() {
Queue<MouseAction> result = Queues.newArrayDeque();
while (Mouse.next()) {
if (Mouse.getEventButton() != -1) {
ButtonState state = (Mouse.getEventButtonState()) ? ButtonState.DOWN : ButtonState.UP;
result.add(new MouseAction(InputType.MOUSE_BUTTON.getInput(Mouse.getEventButton()), state, getPosition()));
}
if (Mouse.getEventDWheel() != 0) {
int id = (Mouse.getEventDWheel() > 0) ? 1 : -1;
result.add(new MouseAction(InputType.MOUSE_WHEEL.getInput(id), id * Mouse.getEventDWheel() / 120, getPosition()));
}
}
return result;
}
代码示例来源:origin: libgdx/libgdx
if (Mouse.getEventButtonState()) {
event.type = TouchEvent.TOUCH_DOWN;
pressedButtons.add(event.button);
代码示例来源:origin: libgdx/libgdx
if (Mouse.getEventButtonState()) {
event.type = TouchEvent.TOUCH_DOWN;
pressedButtons.add(event.button);
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
Mouse.getEventButtonState(), x, y);
evt.setTime(Mouse.getEventNanoseconds());
listener.onMouseButtonEvent(evt);
代码示例来源:origin: Mine-and-blade-admin/Battlegear2
@Override
public void draw(int x, int y, int[] pixels, int rgb, boolean shift) {
if(Mouse.getEventButton() == 0 &&(!Mouse.getEventButtonState()) && last_x > -1000 && last_y > -1000){
if(shift){
if(last_y > y)
y = last_y - Math.abs(last_x - x);
else
y = last_y + Math.abs(last_x - x);
}
drawShape(Math.min(last_x, x),
Math.min(last_y, y),
Math.max(last_x, x),
Math.max(last_y, y),
pixels,
rgb);
}
}
代码示例来源:origin: org.ode4j/demo
/**
* reads a mouse in buffered mode
*/
private void readBufferedMouse() {
// iterate all events, use the last button down
while(Mouse.next()) {
if (Mouse.getEventButton() != -1) {
if (Mouse.getEventButtonState()) {
}
//lastButton = Mouse.getEventButton();
}
}
updateState();
}
代码示例来源:origin: RS485/LogisticsPipes
public void preRender() {
if (isOverlaySlotActive) {
// Save Mouse Pos
oldX = Mouse.getX();
oldY = Mouse.getY();
// Set Pos 0,0
try {
fX.set(null, 0);
fY.set(null, 0);
hasBeenSaved = true;
} catch (Exception e) {
if (LPConstants.DEBUG) {
e.printStackTrace();
}
}
while (Mouse.next()) {
if (Mouse.getEventButton() == 0 && Mouse.getEventButtonState()) {
clicked = true;
}
}
}
}
代码示例来源:origin: Vazkii/Quark
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onMousePress(GuiScreenEvent.MouseInputEvent.Pre event) {
if(Mouse.getEventButtonState() && Minecraft.getMinecraft().currentScreen != null)
registerPress();
}
代码示例来源:origin: Vazkii/Quark
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onMousePress(MouseInputEvent event) {
if(Mouse.getEventButtonState() && Minecraft.getMinecraft().currentScreen != null)
registerPress();
}
代码示例来源:origin: nifty-gui/nifty-gui
private void processMouseEvents(@Nonnull final NiftyInputConsumer inputEventConsumer) {
int viewportHeight = getViewportHeight();
while (Mouse.next()) {
int mouseX = Mouse.getEventX();
int mouseY = viewportHeight - Mouse.getEventY();
int mouseWheel = Mouse.getEventDWheel() / 120; // not sure about that 120 here. works on my system and makes
// this return 1 if the wheel is moved the minimal amount.
int button = Mouse.getEventButton();
boolean buttonDown = Mouse.getEventButtonState();
// now send the event to nifty
boolean mouseEventProcessedByNifty = inputEventConsumer.processMouseEvent(mouseX, mouseY, mouseWheel, button,
buttonDown);
if (!mouseEventProcessedByNifty) {
log.fine("Nifty did not processed this mouse event. You can handle it.");
// nifty did not process this event, it did not hit any element
mouseEventsOut.offer(new MouseInputEvent(mouseX, mouseY, mouseWheel, button, buttonDown));
if (niftyTakesKeyboardFocusOnClick) {
log.fine("Nifty gave up the keyboard focus");
niftyHasKeyboardFocus = false; // give up focus if clicked outside nifty
}
} else {
log.fine("Nifty has processed this mouse event");
// nifty did handle that event. it hit an element and was processed by some GUI element
if (niftyTakesKeyboardFocusOnClick) { // take focus if nifty element is clicked
log.fine("Nifty takes the keyboard focus back");
niftyHasKeyboardFocus = true;
}
}
}
}
代码示例来源:origin: ForestryMC/Binnie
public boolean isHelpMode() {
if (Keyboard.getEventKeyState()) {
if (KeyBindings.holdForHelpTooltips.isActiveAndMatches(Keyboard.getEventKey())) {
return true;
}
}
return Mouse.getEventButtonState() && KeyBindings.holdForHelpTooltips.isActiveAndMatches(Mouse.getEventButton() - 100);
}
代码示例来源:origin: Vazkii/Quark
@SubscribeEvent
public void onMouseclick(GuiScreenEvent.MouseInputEvent.Pre event) {
if(searchBar != null && Mouse.getEventButtonState()) {
Minecraft mc = Minecraft.getMinecraft();
GuiScreen gui = event.getGui();
int x = Mouse.getEventX() * gui.width / mc.displayWidth;
int y = gui.height - Mouse.getEventY() * gui.height / mc.displayHeight - 1;
int button = Mouse.getEventButton();
searchBar.mouseClicked(x, y, button);
long time = System.currentTimeMillis();
long delta = time - lastClick;
if(delta < 200 && searchBar.isFocused()) {
searchBar.setText("");
text = "";
}
lastClick = time;
}
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
@Override
public void handleMouseInput() throws IOException {
super.handleMouseInput();
int x = Mouse.getEventX() * this.width / this.mc.displayWidth;
int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
int button = Mouse.getEventButton();
boolean state = Mouse.getEventButtonState();
int wheel = Mouse.getEventDWheel();
int type = button >= 0 ? (state ? Listener.MOUSE_DOWN : Listener.MOUSE_UP) : wheel != 0 ? Listener.MOUSE_WHEEL : Listener.MOUSE_MOVED;
ActivationEvent evt = new ActivationEvent(type, button, state, x, y, wheel);
for (GuiElement element : this.elements) {
element.handleMouseInput(evt);
}
}
代码示例来源:origin: Funwayguy/BetterQuesting
@Override
public void handleMouseInput() throws IOException
{
super.handleMouseInput();
int i = Mouse.getEventX() * width / mc.displayWidth;
int j = height - Mouse.getEventY() * height / mc.displayHeight - 1;
int k = Mouse.getEventButton();
int SDX = (int)-Math.signum(Mouse.getEventDWheel());
boolean flag = Mouse.getEventButtonState();
if(k >= 0 && k < 3 && mBtnState[k] != flag)
{
if(flag)
{
this.onMouseClick(i, j, k);
} else
{
this.onMouseRelease(i, j, k);
}
mBtnState[k] = flag;
}
if(SDX != 0)
{
this.onMouseScroll(i, j, SDX);
}
}
代码示例来源:origin: Funwayguy/BetterQuesting
@Override
public void handleMouseInput() throws IOException
{
super.handleMouseInput();
int i = Mouse.getEventX() * width / mc.displayWidth;
int j = height - Mouse.getEventY() * height / mc.displayHeight - 1;
int k = Mouse.getEventButton();
int SDX = (int)-Math.signum(Mouse.getEventDWheel());
boolean flag = Mouse.getEventButtonState();
if(k >= 0 && k < 3 && mBtnState[k] != flag)
{
if(flag)
{
this.onMouseClick(i, j, k);
} else
{
this.onMouseRelease(i, j, k);
}
mBtnState[k] = flag;
}
if(SDX != 0)
{
this.onMouseScroll(i, j, SDX);
}
}
代码示例来源:origin: Mine-and-blade-admin/Battlegear2
@Override
public void handleMouseInput() throws IOException {
super.handleMouseInput();
int x = (Mouse.getEventX() * this.width / this.mc.displayWidth -(x_canvus_start))/canvusMult;
int y = (this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1 - (y_canvus_start))/canvusMult;
if(! Mouse.getEventButtonState() && Mouse.getEventButton() == 0){
if(selectedTool instanceof RectangleTool){
int next = (bufferPointer+1) % BUFFER_SIZE;
imageBuffer[next] = Arrays.copyOf(imageBuffer[bufferPointer], ImageData.IMAGE_RES * ImageData.IMAGE_RES);
bufferPointer = next;
//Clear the next
imageBuffer[(bufferPointer+1) % BUFFER_SIZE] = null;
selectedTool.draw(x, y, imageBuffer[bufferPointer], ImageData.roundColour(colourPicker.getRGB()), Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT));
}
}
selectedTool.drawOverlay(x,y,imageBuffer[bufferPointer],overlay, ImageData.roundColour(colourPicker.getRGB()), Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT));
}
代码示例来源:origin: mezz/JustEnoughItems
public boolean handleMouseEvent(GuiScreen guiScreen, int mouseX, int mouseY) {
boolean cancelEvent = false;
final int eventButton = Mouse.getEventButton();
if (eventButton > -1) {
if (Mouse.getEventButtonState()) {
if (!clickHandled.contains(eventButton)) {
cancelEvent = handleMouseClick(guiScreen, eventButton, mouseX, mouseY);
if (cancelEvent) {
clickHandled.add(eventButton);
}
}
} else if (clickHandled.contains(eventButton)) {
clickHandled.remove(eventButton);
cancelEvent = true;
}
} else if (Mouse.getEventDWheel() != 0) {
cancelEvent = handleMouseScroll(Mouse.getEventDWheel(), mouseX, mouseY);
}
return cancelEvent;
}
代码示例来源:origin: SleepyTrousers/EnderIO
public void handleMouseInput() {
dragging = Mouse.getEventButtonState();
if (!Mouse.getEventButtonState() && camera.isValid() && elapsed > 500) {
if (Mouse.getEventButton() == 1) {
if (selection != null) {
代码示例来源:origin: threerings/playn
@Override
void update() {
while (Mouse.next()) {
double time = (double) (Mouse.getEventNanoseconds() / 1000000);
int btn = getButton(Mouse.getEventButton());
Point m = new Point(Mouse.getEventX(), Display.getHeight() - Mouse.getEventY() - 1);
platform.graphics().transformMouse(m);
int dx = Mouse.getEventDX(), dy = -Mouse.getEventDY();
if (btn != -1) {
if (Mouse.getEventButtonState()) {
onMouseDown(time, m.x, m.y, btn);
} else {
onMouseUp(time, m.x, m.y, btn);
}
} else if (Mouse.getEventDWheel() != 0) {
int delta = Mouse.getEventDWheel() > 0 ? -1 : 1;
onMouseWheelScroll(time, m.x, m.y, delta);
} else {
onMouseMove(time, m.x, m.y, dx, dy);
}
}
}
代码示例来源:origin: com.googlecode.playn/playn-java
@Override
void update() {
while (Mouse.next()) {
double time = (double) (Mouse.getEventNanoseconds() / 1000000);
int btn = getButton(Mouse.getEventButton());
Point m = new Point(Mouse.getEventX(), Display.getHeight() - Mouse.getEventY() - 1);
platform.graphics().transformMouse(m);
int dx = Mouse.getEventDX(), dy = -Mouse.getEventDY();
if (btn != -1) {
if (Mouse.getEventButtonState()) {
onMouseDown(time, m.x, m.y, btn);
} else {
onMouseUp(time, m.x, m.y, btn);
}
} else if (Mouse.getEventDWheel() != 0) {
int delta = Mouse.getEventDWheel() > 0 ? -1 : 1;
onMouseWheelScroll(time, m.x, m.y, delta);
} else {
onMouseMove(time, m.x, m.y, dx, dy);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!