コード例 #1
0
ファイル: button.cpp プロジェクト: Badrpas/LD26
void RectangleButton::Update(){
	isPressed = wasPressed = false;
	if (mouseIn()){
		select();
		if (mouseX_pre != mouseX && mouseY_pre != mouseY && onMouseIn)
			onMouseIn();
		if (hge->Input_KeyUp(HGEK_LBUTTON)){
			if(onMouseClick)
			onMouseClick();
			wasPressed = true;
		}
		if (hge->Input_GetKeyState(HGEK_LBUTTON)){
			float mod = 0.5;
			captionDx *= mod;
			captionDy *= mod;
			isPressed = true;
		}
	}else{
		deselect();
		if (in(mouseX_pre, mouseY_pre) && onMouseOut)
			onMouseOut();
	}
}
コード例 #2
0
ファイル: widget.cpp プロジェクト: AMouri/Rouge
void Widget::update(const TCOD_key_t k) {
	bool curs=TCODMouse::isCursorVisible();
	if ( curs ) {
		if ( mouse.cx >= x && mouse.cx < x+w && mouse.cy >= y && mouse.cy < y+h ) {
			if ( ! mouseIn ) {
				mouseIn = true;
				onMouseIn();
			}
			if ( focus != this ) {
				focus=this;
			}
		} else {
			if ( mouseIn ) {
				mouseIn = false;
				onMouseOut();
			}
			mouseL=false;
			if ( this == focus ) {
				focus = NULL;
			}
		}
	}
	if ( mouseIn || (! curs && this == focus ) ) {
		if ( mouse.lbutton && ! mouseL ) {
			mouseL = true;
			onButtonPress();
		} else if (! mouse.lbutton && mouseL ) {
			onButtonRelease();
			keyboardFocus=NULL;
			if ( mouseL ) onButtonClick();
			mouseL=false;
		} else if ( mouse.lbutton_pressed ) {
			keyboardFocus=NULL;
			onButtonClick();
		}
	}
}