Java Code Examples for org.lwjgl.glfw.GLFW#glfwGetMouseButton()

The following examples show how to use org.lwjgl.glfw.GLFW#glfwGetMouseButton() . 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: Lwjgl3Mini2DxInput.java    From mini2Dx with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isTouched() {
	return GLFW.glfwGetMouseButton(window.getWindowHandle(), GLFW.GLFW_MOUSE_BUTTON_1) == GLFW.GLFW_PRESS ||
			GLFW.glfwGetMouseButton(window.getWindowHandle(), GLFW.GLFW_MOUSE_BUTTON_2) == GLFW.GLFW_PRESS ||
			GLFW.glfwGetMouseButton(window.getWindowHandle(), GLFW.GLFW_MOUSE_BUTTON_3) == GLFW.GLFW_PRESS ||
			GLFW.glfwGetMouseButton(window.getWindowHandle(), GLFW.GLFW_MOUSE_BUTTON_4) == GLFW.GLFW_PRESS ||
			GLFW.glfwGetMouseButton(window.getWindowHandle(), GLFW.GLFW_MOUSE_BUTTON_5) == GLFW.GLFW_PRESS;
}
 
Example 2
Source File: Slider.java    From LWJGUI with MIT License 4 votes vote down vote up
@Override
public void render(Context context) {
	if ( !isVisible() )
		return;
	
	if ( orientation == HORIZONTAL ) {
		pos = Slider.this.getX();
		len = Slider.this.getWidth();
	}
	else {
		pos = Slider.this.getY();
		len = Slider.this.getHeight();
	}
	
	if ( dragged ) {
		MouseHandler mh = window.getMouseHandler();
		double mousePos;
		
		if ( orientation == HORIZONTAL ) 
			mousePos = mh.getX();
		else
			mousePos = mh.getY();
		
		double t = mouseSpaceToTrackSpace(mousePos-bOff);
		setValue(t);
	}
	
	if ( GLFW.glfwGetMouseButton(GLFW.glfwGetCurrentContext(), GLFW.GLFW_MOUSE_BUTTON_LEFT)!=GLFW.GLFW_PRESS )
		dragged = false;

	double v = trackSpaceToMouseSpace(value);
	
	if ( orientation == HORIZONTAL ) {
		this.setAbsolutePosition(v-getWidth()/2, getY());
		// Limit the position of the thumb
		if ( this.absolutePosition.x < pos )
			this.absolutePosition.x = pos;
		if ( this.absolutePosition.x > pos + len - this.getWidth() )
			this.absolutePosition.x = pos + len - this.getWidth();
	}
	else {
		this.setAbsolutePosition(getX(), v-getHeight()/2);
		// Limit the position of the thumb
		if ( this.absolutePosition.y < pos )
			this.absolutePosition.y = pos;
		if ( this.absolutePosition.y > pos + len - this.getWidth() )
			this.absolutePosition.y = pos + len - this.getWidth();
	}
	
	super.render(context);
}
 
Example 3
Source File: Lwjgl3Mini2DxInput.java    From mini2Dx with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isButtonPressed(int button) {
	return GLFW.glfwGetMouseButton(window.getWindowHandle(), button) == GLFW.GLFW_PRESS;
}