Beispiel #1
0
void line_edit_control::delete_word_forward()
{
	set_key_state( ks_Shift, true );
	move_pos_right_word();
	compute_positions();
	delete_selected( false );
	set_key_state( ks_Shift, false );
}
Beispiel #2
0
void line_edit_control::delete_word_back()
{
	set_key_state( ks_Shift, true );
	move_pos_left_word();
	compute_positions();
	delete_selected( true );
	set_key_state( ks_Shift, false );
}
Beispiel #3
0
void line_edit_control::on_key_release( int dik )
{
	m_accel         = 1.0f;
	m_rep_time      = 0.0f;
	m_last_key_time = 0.0f;

	switch ( dik )
	{
	case DIK_LSHIFT:	set_key_state( ks_LShift, false );	break;
	case DIK_RSHIFT:	set_key_state( ks_RShift, false );	break;
	case DIK_LCONTROL:	set_key_state( ks_LCtrl,  false );	break;
	case DIK_RCONTROL:	set_key_state( ks_RCtrl,  false );	break;
	case DIK_LALT:		set_key_state( ks_LAlt,   false );	break;
	case DIK_RALT:		set_key_state( ks_RAlt,   false );	break;
	}
	update_bufs();
}
/// Poll events.
///
/// Returns true if an event was fetched.
///
/// @warning This must be called on the thread that created the
/// windows.
bool input_buffer::poll(
	InputBuffer& ib,
	InputEventType& type,
	InputEvent const*& event
) {
	if (!ib._buffer._consume_mode) {
		window::process_events(ib);
		if (!object_buffer::empty(ib._buffer)) {
			object_buffer::begin_consume(ib._buffer);
		} else {
			return false;
		}
	} else {
		if (!object_buffer::has_more(ib._buffer)) {
			object_buffer::end_consume(ib._buffer);
			return false;
		}
	}
	void const* vptr = nullptr;
	object_buffer::read(ib._buffer, type, vptr);
	event = static_cast<InputEvent const*>(vptr);
	#if defined(TOGO_TEST_INPUT_BUFFER)
		switch (type) {
		case InputEventType::key:
			TOGO_TEST_LOGF(
				"input event: %p => "
				"key: action = %u  code = %u  mods = %u\n",
				event->window,
				unsigned_cast(event->key.action),
				unsigned_cast(event->key.code),
				unsigned_cast(event->key.mods)
			);
			break;
		case InputEventType::mouse_button:
			TOGO_TEST_LOGF(
				"input event: %p => "
				"mouse_button: action = %u   button = %u\n",
				event->window,
				unsigned_cast(event->mouse_button.action),
				unsigned_cast(event->mouse_button.button)
			);
			break;
		case InputEventType::mouse_motion:
			/*TOGO_TEST_LOGF(
				"input event: %p => "
				"mouse_motion: (%d, %d)\n",
				event->window,
				event->mouse_motion.x, event->mouse_motion.y
			);*/
			break;
		case InputEventType::window_focus:
			TOGO_TEST_LOGF(
				"input event: %p => "
				"window_focus: focused = %s\n",
				event->window,
				event->window_focus.focused ? "true" : "false"
			);
			break;
		case InputEventType::window_close_request:
			TOGO_TEST_LOGF(
				"input event: %p => "
				"window_close_request\n",
				event->window
			);
			break;
		case InputEventType::window_resize:
			TOGO_TEST_LOGF(
				"input event: %p => "
				"window_resize: (%-4u, %-4u) -> (%-4u, %-4u)\n",
				event->window,
				event->window_resize.old_size.width,
				event->window_resize.old_size.height,
				event->window_resize.new_size.width,
				event->window_resize.new_size.height
			);
			break;
		case InputEventType::window_backbuffer_dirtied:
			TOGO_TEST_LOGF(
				"input event: %p => "
				"window_backbuffer_dirtied\n",
				event->window
			);
			break;
		}
	#endif
	switch (type) {
	case InputEventType::key:
		set_key_state(event->key);
		break;

	case InputEventType::mouse_button:
		if (event->mouse_button.action == MouseButtonAction::press) {
			event->window->_mouse_button_states[
				unsigned_cast(event->mouse_button.button)
			] |= 1 << unsigned_cast(event->mouse_button.action);
		} else if (event->mouse_button.action == MouseButtonAction::release) {
			event->window->_mouse_button_states[
				unsigned_cast(event->mouse_button.button)
			]  = 1 << unsigned_cast(event->mouse_button.action);
		}
		break;

	case InputEventType::mouse_motion:
		event->window->_mouse_x = event->mouse_motion.x;
		event->window->_mouse_y = event->mouse_motion.y;
		break;

	default:
		break;
	};
	return true;
}
Beispiel #5
0
void set_key(int channel, int state) {
	_channel=channel;
	set_key_state(state);
}