CMM: mouse: new event drag

git-svn-id: svn://kolibrios.org@5657 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pavelyakov 2015-08-02 23:43:40 +00:00
parent b8267310e8
commit db3c02d4c3
2 changed files with 30 additions and 18 deletions

View File

@ -189,13 +189,13 @@ void main()
if (param) if (param)
{ {
tmp = strlen(#path); tmp = strlen(#path);
strncpy(#path, #param, tmp); strlcpy(#path, #param, tmp);
$dec tmp $dec tmp
if (path[tmp]!='/') DSBYTE[#path+tmp] = '/'; //add "/" to the end of the string if (path[tmp]!='/') DSBYTE[#path+tmp] = '/'; //add "/" to the end of the string
} }
else else
{ {
strncpy(#path, "/rd/1/", 6); strlcpy(#path, "/rd/1/", 6);
} }
Open_Dir(#path,ONLY_OPEN); Open_Dir(#path,ONLY_OPEN);
SetEventMask(1100111b); SetEventMask(1100111b);
@ -213,7 +213,7 @@ void main()
mouse.get(); mouse.get();
if (!mouse.mkm) && (stats>0) stats = 0; if (!mouse.mkm) && (stats>0) stats = 0;
if (mouse.mkm) && (stats==0) if (mouse.mkm) && (!stats)
{ {
x_old = mouse.x; x_old = mouse.x;
y_old = mouse.y; y_old = mouse.y;
@ -252,7 +252,7 @@ void main()
} }
} }
} }
if (files.MouseOver(mouse.x, mouse.y))&&((mouse.up)||(mouse.down)||(mouse.dblclick)) if (files.MouseOver(mouse.x, mouse.y))&&((mouse.down)||(mouse.dblclick))
{ {
//select/open file { //select/open file {
if (mouse.key&MOUSE_LEFT)&&((mouse.down)||(mouse.dblclick)) if (mouse.key&MOUSE_LEFT)&&((mouse.down)||(mouse.dblclick))
@ -263,7 +263,7 @@ void main()
if (files.current!=id) if (files.current!=id)
{ {
mouse.clearTime(); mouse.clearTime();
if (id<files.visible) List_Current(id-files.current); if(id<files.visible) List_Current(id-files.current);
} }
else if(mouse.dblclick)Open(0); else if(mouse.dblclick)Open(0);
} }

View File

@ -4,7 +4,6 @@
#startaddress 0 #startaddress 0
#code32 TRUE #code32 TRUE
char os_name[8] = {'M','E','N','U','E','T','0','1'}; char os_name[8] = {'M','E','N','U','E','T','0','1'};
dword os_version = 0x00000001; dword os_version = 0x00000001;
dword start_addr = #______INIT______; dword start_addr = #______INIT______;
@ -93,12 +92,13 @@ char program_path[4096];
* move - event MOUSE movements * move - event MOUSE movements
* click - when clicked * click - when clicked
* dblclick - double-click the default 50 (500 ms) * dblclick - double-click the default 50 (500 ms)
* drag - drag the element event
*/ */
:dword __TMP_TIME,MOUSE_TIME; :dword __TMP_TIME,MOUSE_TIME;
:struct MOUSE :struct MOUSE
{ {
signed x,y,xx,yy,lkm,mkm,pkm,key,tmp,tmp_time,hor,vert,down,up,move,click,dblclick,left,top; signed x,y,xx,yy,lkm,mkm,pkm,key,tmp,tmp_time,hor,vert,down,up,move,click,dblclick,drag,left,top;
dword handle,_; dword handle,_;
byte cmd; byte cmd;
void clearTime(); void clearTime();
@ -203,14 +203,26 @@ char program_path[4096];
mkm = ECX; mkm = ECX;
//when you release the MOUSE button //when you release the MOUSE button
// Mouse Move Event
if(xx!=x)||(yy!=y)
{
move = true;
xx = x;
yy = y;
}
else move = false;
// Mouse Up Event // Mouse Up Event
if((cmd)&&!(key)){ if(cmd)&&(!key){
up = true; up = true;
down = false; down = false;
drag = false;
if(!move) click = true; if(!move) click = true;
move = false;
__TMP_TIME = GetStartTime(); __TMP_TIME = GetStartTime();
if(__TMP_TIME-tmp_time<=MOUSE_TIME){ dblclick = true;click = false; } if(__TMP_TIME-tmp_time<=MOUSE_TIME)
{
dblclick = true;
click = false;
}
tmp_time = __TMP_TIME; tmp_time = __TMP_TIME;
//returns the key code //returns the key code
key = tmp; key = tmp;
@ -224,20 +236,20 @@ char program_path[4096];
//when you press the MOUSE button //when you press the MOUSE button
// Mouse Down Event/Move Event // Mouse Down Event/Move Event
else { else
{
up = false; up = false;
click = false; click = false;
dblclick = false; dblclick = false;
down = false; down = false;
// Mouse Move Event // Mouse Move Event
if((xx!=x)||(yy!=y)) if(key)if(!cmd)
{ {
move = true; down = true;
xx = x; if(move)drag = true;
yy = y; cmd = true;
tmp=key;
} }
else move = false;
if(key)if(!cmd) {down = true;cmd = true;tmp=key;}
} }
//scroll //scroll