Exemplo n.º 1
0
static int
on_event(struct rtb_element *elem, const struct rtb_event *e)
{
	SELF_FROM(elem);

	switch (e->type) {
	case RTB_MOUSE_DOWN:
	case RTB_DRAG_START:
		return 1;

	case RTB_KEY_PRESS:
		if (handle_key_press(self, RTB_EVENT_AS(e, rtb_key_event)))
			return 1;
		break;

	case RTB_MOUSE_CLICK:
		if (RTB_EVENT_AS(e, rtb_mouse_event)->button != RTB_MOUSE_BUTTON1)
			return 0;

		return dispatch_click_event(self, RTB_EVENT_AS(e, rtb_mouse_event));

	default:
		return super.on_event(elem, e);
	}

	return 0;
}
Exemplo n.º 2
0
int
rtb_elem_deliver_event(struct rtb_element *self, const struct rtb_event *e)
{
	int ret;

	/* elements should not receive events if they've not been attached
	 * into the tree yet. */
	if (self->state == RTB_STATE_UNATTACHED)
		return 0;

	ret = self->on_event(self, e);
	ret = rtb_handle(self, e) || ret;

	switch (e->type) {
	case RTB_MOUSE_ENTER:
		transition_mouse_enter(self, RTB_EVENT_AS(e, rtb_mouse_event));
		break;

	case RTB_MOUSE_LEAVE:
		transition_mouse_leave(self, RTB_EVENT_AS(e, rtb_mouse_event));
		break;

	case RTB_FOCUS:
		transition_focus(self);
		break;

	case RTB_UNFOCUS:
		transition_unfocus(self);
		break;

	case RTB_MOUSE_DOWN:
		transition_mouse_down(self, RTB_EVENT_AS(e, rtb_mouse_event));
		break;

	case RTB_MOUSE_UP:
	case RTB_DRAG_DROP:
		transition_mouse_up(self, RTB_EVENT_AS(e, rtb_mouse_event));
		break;
	}

	return ret;
}
Exemplo n.º 3
0
Arquivo: basic.c Projeto: wrl/rutabaga
static int
button_clicked(struct rtb_element *tgt,
		const struct rtb_event *_e, void *ctx)
{
	const struct rtb_button_event *e = RTB_EVENT_AS(_e, rtb_button_event);

	if (e->mod_keys) {
		if (clicks > 0)
			clicks--;
	} else
		clicks++;

	update_label();

	return 0;
}