function StartMop() global mop_x as integer `mouse-x global mop_y as integer `mouse-y global mop_mx as integer `move-x global mop_my as integer `move-y global mop_mz as integer `move-z global mop_left as integer `mouseclick left global mop_right as integer `mouseclick right global mop_top as integer `mouse-wheel pressed global mop_nleft as integer `leftbutton new pressed global mop_nright as integer global mop_ntop as integer global mop_lleft as integer `leftbutton was pressed last round global mop_lright as integer global mop_ltop as integer global mop_lcl as integer `last left-click (timer) global mop_lcr as integer global mop_lct as integer global mop_lclx as integer `x-pos of the last click global mop_lcly as integer global mop_lcrx as integer global mop_lcry as integer global mop_lctx as integer global mop_lcty as integer global mop_dcl as integer `double-click left global mop_dcr as integer global mop_dct as integer global mop_dcDelay as dword `Double-click-delay (time between to clicks) global mop_dcSamePos as boolean `if both clicks have to be on the same position mop_dcDelay = 250 mop_dcSamePos = 1 rem Drag&Drop global mop_dragged as boolean global mop_dragstartx as integer global mop_dragstarty as integer global mop_dragdifx as integer global mop_dragdify as integer global mop_dragrelx as integer global mop_dragrely as integer rem Mouse-Locking global mop_locked as boolean global mop_LockX as integer global mop_LockY as integer rem Zones global mop_Zones as integer global mop_ZoneFillColor as dword global mop_ZoneBorderColor as dword global mop_ZoneTextColor as dword dim mop_Zone(-1) as mop_ZoneType mop_Zones = -1 mop_ZoneBorderColor = rgb(255,255,255) mop_ZoneFillColor = rgb(128,128,128) mop_ZoneTextColor = rgb(255,0,0) endfunction type mop_ZoneType x1 as integer y1 as integer x2 as integer y2 as integer endtype function mop_SetDoubleClickDelay(time) mop_dcDelay = time endfunction function mop_SetDoubleClickSamePos(SamePos as boolean) mop_dcSamePos = SamePos endfunction function mop_Update() mx = mousex() my = mousey() mop_mx = mx-mop_x mop_my = my-mop_y mop_mz = mousemovez() mop_x = mx mop_y = my rem Lock mouse if mop_Locked = 1 position mouse mop_LockX, mop_LockY endif rem Buttons pressed mc = mouseclick() left = ((mc=1) or (mc=3) or (mc=5)) right = ((mc=2) or (mc=3) or (mc=6)) top = ((mc=4) or (mc=5) or (mc=6)) if mc=7 then left=1 : right=1 : top=1 rem Left button ----- if mop_dcl = 1 then mop_dcl = 0 if left = 1 `left pressed if mop_nleft=1 then mop_nleft = 0 if mop_lleft=0 then mop_nleft = 1 mop_left = 1 else `left is not pressed lc = mop_lcl : lcx = mop_lclx : lcy = mop_lcly if mop_lleft = 1 `left was pressed last round mop_left = 0 mop_nleft = -1 mop_lclx = mop_x : mop_lcly = mop_y mop_lcl = timer() if (((timer()-lc)<=mop_dcdelay) and ((lcx=mop_x) and (lcy=mop_y) or (mop_dcSamePos=0))) then mop_dcl = 1 else mop_dcl = 0 else `left was not pressed mop_nleft = 0 endif endif mop_lleft = mop_left rem right button ----- if mop_dcr = 1 then mop_dcr = 0 if right = 1 `right pressed if mop_nright=1 then mop_nright = 0 if mop_lright=0 then mop_nright = 1 mop_right = 1 else `right is not pressed lc = mop_lcr : lcx = mop_lcrx : lcy = mop_lcry if mop_lright = 1 `right was pressed last round mop_right = 0 mop_nright = -1 mop_lcrx = mop_x : mop_lcry = mop_y mop_lcr = timer() if (((timer()-lc)<=mop_dcdelay) and ((lcx=mop_x) and (lcy=mop_y) or (mop_dcSamePos=0))) then mop_dcr = 1 else mop_dcr = 0 else `right was not pressed mop_nright = 0 endif endif mop_lright = mop_right rem top button ----- if mop_dct = 1 then mop_dct = 0 if top = 1 `top pressed if mop_ntop=1 then mop_ntop = 0 if mop_ltop=0 then mop_ntop = 1 mop_top = 1 else `top is not pressed lc = mop_lct : lcx = mop_lctx : lcy = mop_lcty if mop_ltop = 1 `top was pressed last round mop_top = 0 mop_ntop = -1 mop_lctx = mop_x : mop_lcty = mop_y mop_lct = timer() if (((timer()-lc)<=mop_dcdelay) and ((lcx=mop_x) and (lcy=mop_y) or (mop_dcSamePos=0))) then mop_dct = 1 else mop_dct = 0 else `top was not pressed mop_ntop = 0 endif endif mop_ltop = mop_top rem End of this part ----- endfunction function mop_PosX() endfunction mop_x function mop_PosY() endfunction mop_y function mop_MoveX() endfunction mop_mx function mop_MoveY() endfunction mop_my function mop_MoveZ() endfunction mop_mz function mop_Click(Button) select Button case 1 : exitfunction mop_left : endcase case 2 : exitfunction mop_right : endcase case 3 : exitfunction mop_top : endcase endselect endfunction 0 function mop_NewClick(Button) select Button case 1 : exitfunction mop_nleft : endcase case 2 : exitfunction mop_nright : endcase case 3 : exitfunction mop_ntop : endcase endselect endfunction 0 function mop_DoubleClick(Button) select Button case 1 : exitfunction mop_dcl : endcase case 2 : exitfunction mop_dcr : endcase case 3 : exitfunction mop_dct : endcase endselect endfunction 0 function mop_InField(x1,y1,x2,y2) if mop_y <= y2 if mop_y => y1 if mop_x <= x2 if mop_x => x1 exitfunction 1 endif endif endif endif endfunction 0 function mop_CreateZone(x1,y1,w,h) x2 = x1+w y2 = y1+h inc mop_Zones array insert at bottom mop_Zone(0), mop_Zones mop_Zone(mop_Zones).x1 = x1 mop_Zone(mop_Zones).y1 = y1 mop_Zone(mop_Zones).x2 = x2 mop_Zone(mop_Zones).y2 = y2 endfunction mop_Zones function mop_GetZoneX(ID) x = mop_Zone(ID).x1 endfunction x function mop_GetZoneY(ID) y = mop_Zone(ID).y1 endfunction y function mop_GetZoneX2(ID) x2 = mop_Zone(ID).x2 endfunction x2 function mop_GetZoneY2(ID) y2 = mop_Zone(ID).y2 endfunction y2 function mop_GetZoneWidth(ID) w = mop_Zone(ID).x2 - mop_Zone(ID).x1 endfunction w function mop_GetZoneHeight(ID) h = mop_Zone(ID).y2 - mop_Zone(ID).y1 endfunction h function mop_PositionZone(ID,X,Y) w = mop_Zone(ID).x2-mop_Zone(ID).x1 h = mop_Zone(ID).y2-mop_Zone(ID).y1 mop_Zone(ID).x1 = x mop_Zone(ID).y1 = y mop_Zone(ID).x2 = x+w mop_Zone(ID).y2 = y+h endfunction function mop_RelPositionZone(ID,xadd,yadd) inc mop_Zone(ID).x1, xadd inc mop_Zone(ID).y1, yadd inc mop_Zone(ID).x2, xadd inc mop_Zone(ID).y2, yadd endfunction function mop_InZone(ID) if mop_y <= mop_Zone(ID).y2 if mop_y => mop_Zone(ID).y1 if mop_x <= mop_Zone(ID).x2 if mop_x => mop_Zone(ID).x1 exitfunction 1 endif endif endif endif endfunction 0 function mop_ShowZone(ID,t$,Filled as byte) `Info> Filled: 0=lines, 1=box, 2=lines+box if Filled > 0 ink mop_ZoneFillColor, 0 box mop_Zone(ID).x1+1, mop_Zone(ID).y1+1, mop_Zone(ID).x2, mop_Zone(ID).y2 endif if Filled <> 1 ink mop_ZoneBorderColor, 0 line mop_Zone(ID).x1,mop_Zone(ID).y1,mop_Zone(ID).x2,mop_Zone(ID).y1 line mop_Zone(ID).x1,mop_Zone(ID).y1,mop_Zone(ID).x1,mop_Zone(ID).y2 line mop_Zone(ID).x2,mop_Zone(ID).y2,mop_Zone(ID).x1,mop_Zone(ID).y2 line mop_Zone(ID).x2,mop_Zone(ID).y2,mop_Zone(ID).x2,mop_Zone(ID).y1 endif if t$<>"" ink mop_ZoneTextColor, 0 center text mop_Zone(ID).x1+(mop_Zone(ID).x2-mop_Zone(ID).x1)/2, mop_Zone(ID).y1+(mop_Zone(ID).y2-mop_Zone(ID).y1)/2-text size()/2, t$ endif endfunction function mop_SetZoneColors(Txt as dword, Filll as dword, Border as dword) mop_ZoneTextColor = Txt mop_ZoneFillColor = Filll mop_ZoneBorderColor = Border endfunction function mop_LockMouse(x,y) mop_Locked = 1 mop_LockX = x mop_LockY = y endfunction function mop_UnlockMouse() mop_Locked = 0 endfunction function mop_GetLocked() endfunction mop_Locked function mop_GetLockX() endfunction mop_LockX function mop_GetLockY() endfunction mop_LockY function mop_GetDoubleClickSamePos() endfunction mop_dcSamePos function mop_GetDoubleClickDelay() endfunction mop_dcDelay function mop_Drag() mop_dragged = 1 mop_dragstartx = mop_x mop_dragstarty = mop_y endfunction function mop_DragObject(ObjX,ObjY) mop_dragged = 1 mop_dragrelx = mop_x-ObjX mop_dragrely = mop_y-ObjY endfunction function mop_GetDraggedObjectX() x = mop_x - mop_dragrelx endfunction x function mop_GetDraggedObjectY() y = mop_y - mop_dragrely endfunction y function mop_Drop() mop_dragged = 0 mop_dragdifx = mop_x-mop_dragstartx mop_dragdify = mop_y-mop_dragstarty endfunction function mop_GetDragged() endfunction mop_dragged function mop_GetDragX() endfunction mop_dragstartx function mop_GetDragY() endfunction mop_dragstarty function mop_GetDropXDif() endfunction mop_dragdifx function mop_GetDropYDif() endfunction mop_dragdify