diff --git a/engine/client/console.c b/engine/client/console.c index f857d9c8f..e87147bb3 100644 --- a/engine/client/console.c +++ b/engine/client/console.c @@ -3294,7 +3294,7 @@ void Con_DrawConsole (int lines, qboolean noback) } selactive = Key_GetConsoleSelectionBox(con_current, &selsx, &selsy, &selex, &seley); - if ((con_current->flags & CONF_KEEPSELECTION) && con_current->selstartline && con_current->selendline && con_current->buttonsdown != CB_SELECTED) + if ((con_current->flags & CONF_KEEPSELECTION) && con_current->selstartline && con_current->selendline && con_current->buttonsdown != CB_SELECTED && con_current->buttonsdown != CB_TAPPED) selactive = -1; Font_BeginString(font_console, x, y, &x, &y); @@ -3329,14 +3329,18 @@ void Con_DrawConsole (int lines, qboolean noback) mouseconsole = con_mouseover?con_mouseover:con_current; - if (con_current->buttonsdown == CB_SELECTED) + if (con_current->buttonsdown == CB_SELECTED || con_current->buttonsdown == CB_TAPPED) { //select was released... console_t *con = con_current; char *buffer; + qboolean tapped = con->buttonsdown==CB_TAPPED; con->buttonsdown = CB_NONE; if (con->selstartline) { - con->flags |= CONF_KEEPSELECTION; + if (tapped) + con->flags &= ~CONF_KEEPSELECTION; + else + con->flags |= CONF_KEEPSELECTION; if (con->userline) { if (con->flags & CONF_BACKSELECTION) @@ -3427,6 +3431,57 @@ void Con_DrawOneConsole(console_t *con, qboolean focused, struct font_s *font, f con->display = con->current; Con_DrawConsoleLines(con, con->display, con->displayscroll, x, sx, sy, y, selactive, selsx, selex, selsy, seley, lineagelimit); + + if (con->buttonsdown == CB_SELECTED || con->buttonsdown == CB_TAPPED) + { //select was released... + char *buffer; + qboolean tapped = con->buttonsdown==CB_TAPPED; + con->buttonsdown = CB_NONE; + if (con->selstartline) + { + if (tapped) + con->flags &= ~CONF_KEEPSELECTION; + else + con->flags |= CONF_KEEPSELECTION; + if (con->userline) + { + if (con->flags & CONF_BACKSELECTION) + { + con->userline = con->selendline; + con->useroffset = con->selendoffset; + } + else + { + con->userline = con->selstartline; + con->useroffset = con->selstartoffset; + } + } + if (con->selstartline == con->selendline && con->selendoffset <= con->selstartoffset+1) + { + if (keydown[K_LSHIFT] || keydown[K_RSHIFT]) + ; + else + { + buffer = Con_CopyConsole(con, false, true, false); + if (buffer) + { + Key_HandleConsoleLink(con, buffer); + Z_Free(buffer); + } + } + } + else + { + buffer = Con_CopyConsole(con, true, false, true); //don't keep markup if we're copying to the clipboard + if (buffer) + { + Sys_SaveClipboard(CBT_SELECTION, buffer); + Z_Free(buffer); + } + } + } + } + Font_EndString(font); } diff --git a/engine/client/keys.c b/engine/client/keys.c index a6d0c8d65..2eb180148 100644 --- a/engine/client/keys.c +++ b/engine/client/keys.c @@ -761,7 +761,7 @@ qboolean Key_GetConsoleSelectionBox(console_t *con, int *sx, int *sy, int *ex, i *ey = con->mousecursor[1]; return true; } - else if (con->buttonsdown == CB_SELECT || con->buttonsdown == CB_SELECTED) + else if (con->buttonsdown == CB_SELECT || con->buttonsdown == CB_SELECTED || con->buttonsdown == CB_TAPPED) { //right-mouse //select. copy-to-clipboard on release. @@ -1219,7 +1219,10 @@ void Key_ConsoleRelease(console_t *con, int key, unsigned int unicode) if ((key == K_TOUCHTAP || key == K_MOUSE1) && con->buttonsdown == CB_SELECT) { - con->buttonsdown = CB_SELECTED; + if (fabs(con->mousedown[0] - con->mousecursor[0]) < 5 && fabs(con->mousedown[1] - con->mousecursor[1]) < 5 && realtime < con->mousedowntime + 0.4) + con->buttonsdown = CB_TAPPED; //don't leave it selected. + else + con->buttonsdown = CB_SELECTED; return; } if ((key == K_TOUCHSLIDE || key == K_MOUSE1) && con->buttonsdown == CB_SCROLL)// || (key == K_MOUSE2 && con->buttonsdown == CB_SCROLL_R)) @@ -1276,7 +1279,7 @@ void Key_ConsoleRelease(console_t *con, int key, unsigned int unicode) return; } } - if (con->buttonsdown == CB_SELECTED) + if (con->buttonsdown == CB_SELECTED || con->buttonsdown == CB_TAPPED) ; //will time out in the drawing code. else // if (con->buttonsdown == CB_MOVE) //window title(move) diff --git a/engine/common/console.h b/engine/common/console.h index 898c20a36..002a3c1dc 100644 --- a/engine/common/console.h +++ b/engine/common/console.h @@ -124,7 +124,8 @@ enum CB_MOVE = 4, CB_ACTIONBAR = 5, CB_SELECT = 6, - CB_SELECTED = 7, + CB_SELECTED = 7, //selection ended (deferred until drawing to ensure selections happen properly) + CB_TAPPED = 8, //quick-tap ended (deferred until drawing to ensure selections happen properly) //the flags part CB_STALE = (1u<<28), //WAS held last frame - to make sure we still do stuff when released on the same frame.