Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mouse Select Text Trigger
#2
Toolbar tb_drag_select
Code:
Copy      Help
;/mov {ret xm-10} {ret ym+10}

Function tb_drag_select_f
Trigger #Lh1 0x1 /WORDPAD /FF_tb_drag_select     Help - how to add the trigger to the macro
Code:
Copy      Help
;is drag distance >=4 pixels?
POINT+ g_tbds
POINT p; xm p
if(_hypot(p.x-g_tbds.x p.y-g_tbds.y)<4) ret

;is text selection?
str s.getsel
if(!s.len) ret

int h=win("TB_DRAG_SELECT" "QM_Toolbar")
if(h) mov xm-10 ym+10 h
else mac "tb_drag_select"

Function FF_tb_drag_select (this is filter function. Set it in Properties)
Code:
Copy      Help
;/
function# iid FILTER&f

;if(!childtest(f.hwnd2 ...)) ret -2

POINT+ g_tbds
xm g_tbds
ret iid

;ret iid    - run the macro.
;ret macro    - run other macro. Here 'macro' is its id or name.
;ret 0        - don't run any macros.
;ret -1        - don't run any macros but eat the key. Eg if the filter function started a macro using mac.
;ret -2        - don't run this macro. Other macros with the same trigger can run.

On mouse left button down in client area of a WORDPAD window, runs FF_tb_drag_select. Edit it. ret -2 if it is wrong window or wrong child window. On button up, runs tb_drag_select_f. It measures drag distance, checks whether there is selected text, and if all ok launches the toolbar or moves it to mouse position.


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)