Posts: 1,769
Threads: 410
Joined: Feb 2003
I'd like to have a toolbar pop-up (or several) when I've selected text in a certain program. I there a way to have it trigger toolbars and place them around the mouse pointer when you release the left-button when doing a drag select?
Posts: 12,066
Threads: 140
Joined: Dec 2002
Toolbar tb_drag_select
;/mov {ret xm-10} {ret ym+10}
Function
tb_drag_select_f
Trigger
#Lh1 0x1 /WORDPAD /FF_tb_drag_select
;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)
;/
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.
Posts: 1,769
Threads: 410
Joined: Feb 2003
Posts: 1,769
Threads: 410
Joined: Feb 2003
BTW: let me know when you can make a toolbar circular...that'd be Awesome for this.
Posts: 1,769
Threads: 410
Joined: Feb 2003
is there a way to have it close if i click some where else like a menu (as if i didn't need it) does?
Posts: 12,066
Threads: 140
Joined: Dec 2002
Function
tb_drag_select_f
Trigger
#Lh1 0x1 /WORDPAD /FF_tb_drag_select
;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 h=mac("tb_drag_select")
;wait for click, and close
rep
,wait 0 ML
,if(win(mouse)!=h)
,,clo h
,,break
Posts: 1,769
Threads: 410
Joined: Feb 2003
works great!
since i need it to close even if i choose a toolbar button I changed that new code to this.
Function
tb_drag_select_f
Trigger
#Lh1 0x1 /NOTEPAD++ /FF_tb_drag_select
rep
,wait 0 ML
,clo h
,break