mouse button release events

master
Allen Webster 2016-09-09 13:14:38 -04:00
parent 3de8779d53
commit 602d41be70
7 changed files with 37 additions and 21 deletions

File diff suppressed because one or more lines are too long

View File

@ -342,6 +342,11 @@ default_keys(Bind_Helper *context){
bind(context, key_mouse_left, MDFR_NONE, click_set_cursor);
bind(context, key_mouse_right, MDFR_NONE, click_set_mark);
// NOTE(allen|a4.0.11): You can now bind left and right mouse
// button releases. Modifiers do work so control+click shift+click
// etc can now have special meanings.
bind(context, key_mouse_left_release, MDFR_NONE, click_set_mark);
bind(context, key_left, MDFR_NONE, move_left);
bind(context, key_right, MDFR_NONE, move_right);
bind(context, key_del, MDFR_NONE, delete_char);

View File

@ -13,6 +13,8 @@ key_page_down = 13,
key_esc = 14,
key_mouse_left = 15,
key_mouse_right = 16,
key_mouse_left_release = 17,
key_mouse_right_release = 18,
key_f1 = 127,
key_f2 = 128,
key_f3 = 129,
@ -48,6 +50,8 @@ case key_page_down: result = "page_down"; *size = sizeof("page_down")-1; break;
case key_esc: result = "esc"; *size = sizeof("esc")-1; break;
case key_mouse_left: result = "mouse_left"; *size = sizeof("mouse_left")-1; break;
case key_mouse_right: result = "mouse_right"; *size = sizeof("mouse_right")-1; break;
case key_mouse_left_release: result = "mouse_left_release"; *size = sizeof("mouse_left_release")-1; break;
case key_mouse_right_release: result = "mouse_right_release"; *size = sizeof("mouse_right_release")-1; break;
case key_f1: result = "f1"; *size = sizeof("f1")-1; break;
case key_f2: result = "f2"; *size = sizeof("f2")-1; break;
case key_f3: result = "f3"; *size = sizeof("f3")-1; break;

View File

@ -366,11 +366,9 @@ struct Key_Event_Data{
char modifiers[MDFR_INDEX_COUNT];
};
/* DOC(
Mouse_State describes an entire mouse state complete with the position,
left and right button states, the wheel state, and whether or not the
mouse if in the window.
) */
/* DOC(Mouse_State describes an entire mouse state complete with the
position, left and right button states, the wheel state, and whether
or not the mouse if in the window.) */
struct Mouse_State{
/* DOC(This field indicates that the left button is held.) */
char l;

27
4ed.cpp
View File

@ -1783,10 +1783,7 @@ App_Step_Sig(app_step){
}
Key_Event_Data mouse_event = {0};
if (input->mouse.press_l ||
input->mouse.press_r){
memcpy(mouse_event.modifiers, input->keys.modifiers, sizeof(input->keys.modifiers));
}
memcpy(mouse_event.modifiers, input->keys.modifiers, sizeof(input->keys.modifiers));
if (input->mouse.press_l){
mouse_event.keycode = key_mouse_left;
@ -1798,6 +1795,16 @@ App_Step_Sig(app_step){
key_summary.keys[key_summary.count++] = mouse_event;
}
if (input->mouse.release_l){
mouse_event.keycode = key_mouse_left_release;
key_summary.keys[key_summary.count++] = mouse_event;
}
if (input->mouse.release_r){
mouse_event.keycode = key_mouse_right_release;
key_summary.keys[key_summary.count++] = mouse_event;
}
input->mouse.wheel = -input->mouse.wheel;
}
@ -2436,8 +2443,7 @@ App_Step_Sig(app_step){
if (record->consumed && record->consumer[0] != 0){
Debug_Input_Event *event = debug->input_events;
for (i32 i = 0; i < count; ++i, ++event){
if (event->key == key_mouse_left &&
event->consumer[0] == 0){
if (event->key == key_mouse_left && event->consumer[0] == 0){
memcpy(event->consumer, record->consumer, sizeof(record->consumer));
}
}
@ -2447,8 +2453,7 @@ App_Step_Sig(app_step){
if (record->consumed && record->consumer[0] != 0){
Debug_Input_Event *event = debug->input_events;
for (i32 i = 0; i < count; ++i, ++event){
if (event->key == key_mouse_right &&
event->consumer[0] == 0){
if (event->key == key_mouse_right && event->consumer[0] == 0){
memcpy(event->consumer, record->consumer, sizeof(record->consumer));
}
}
@ -2458,8 +2463,7 @@ App_Step_Sig(app_step){
if (record->consumed && record->consumer[0] != 0){
Debug_Input_Event *event = debug->input_events;
for (i32 i = 0; i < count; ++i, ++event){
if (event->key == key_esc &&
event->consumer[0] == 0){
if (event->key == key_esc && event->consumer[0] == 0){
memcpy(event->consumer, record->consumer, sizeof(record->consumer));
}
}
@ -2491,6 +2495,9 @@ App_Step_Sig(app_step){
" and fullscreen can be toggled with <control pageup>.\n"
" (This sometimes causes artifacts on the Windows task bar)\n"
"-<alt f4> to exit\n"
"-hook on exit for the customization system\n"
"-tokens now exposed in customization system\n"
"-mouse release events in customization system\n"
"\n"
"New in alpha 4.0.10:\n"
"-<control F> list all locations of a string across all open buffers\n"

View File

@ -89,6 +89,8 @@ char *keys_that_need_codes[] = {
"mouse_left",
"mouse_right",
"mouse_left_release",
"mouse_right_release",
"f1",
"f2",

View File

@ -73,6 +73,7 @@
; [X] problem with end of line comments
; [X] paths with parens in them
; [X] killing compilation panel changes active panel
; [X] make panel resizing not whacky with child panels
;
; [] indication on failure to save
; [] history is broken, revist the entire system
@ -86,8 +87,6 @@
; BEFORE I SHIP
;
; [X] make panel resizing not whacky with child panels
; [X] case insensitive interactive switch buffer
; [X] tokens in the custom API
; [X] token seeking on custom side
; [X] auto indent on the custom side
@ -96,7 +95,6 @@
; [] clean up and comment the auto indent code to allow for customizations
; [] more built in options for auto indenting
; [] expose dirty flags
; [] mouse down/up distinction
; [] occasionally missing the (!) mark on files on windows
; [] scroll down on compilation buffer durring compilation
; [] why are command line files not loading any more?
@ -143,6 +141,8 @@
; [X] new file
; [X] hook on exit
; [X] file out of sync
; [X] mouse down/up distinction
; [X] case insensitive interactive switch buffer
;
; [] binary buffers