I can see where mouse event is useful and the drag and drop would be nice. I don't like the addition of 12 individual events as it is too cumbersome and inconsistent. First of all, I would start by noting that almost every option in the on event idea has a one-to-one corresponding menu option - turning them into individual events would be nothing but cosmetics. You could easily turn it into an event dispatch to perform 90% of what you asked.

Lastly, I think the drag/drop events would be nice as a general event (i.e. can be used with #channels as well, I can see nice application for that), so @win should actually be 'target' in that case.

Here is some basic code: (supports mouse enter, leave, move, drag, drop, click, and double click)

Code:
;        on mouse enter event in @window
;
;    - triggers when the mouse is within a specified square in a custom window
;    - Multiple on mouse_event are allowed by cannot overlap.
;
; Params:
;    - %%window -> @window that triggered the event
;    - %%mouse.x -> mouse current x coordinate
;    - %%mouse.x -> mouse current y coordinate
;
on *:signal:$($mouse_enter(50, 50, 100, 100)):{
  echo -s Mouse is in window %%window within the square area (50, 50) and (150, 150)! $&
    At ( $+ %%mouse.x $+ , %%mouse.y $+ ).
}
on *:signal:$($mouse_enter(200, 200, 100, 100)):{
  echo -s Mouse is in window %%window within the square area (200, 200) and (300, 300)! $&
    At ( $+ %%mouse.x $+ , %%mouse.y $+ ).
}

;        on mouse move event in @window
;
;    - triggers when the mouse moves in a custom window
;
; Params:
;    - %%window -> @window that triggered the event
;    - %%mouse.x -> mouse current x coordinate
;    - %%mouse.x -> mouse current y coordinate
;
on *:signal:mouse,move:{
  echo -s Mouse moved in window %%window at ( $+ %%mouse.x $+ , %%mouse.y $+ ).
}

;        on mouse leave event in @window
;
;    - triggers when the mouse leaves a custom window
;
; Params:
;    - %%window -> @window that triggered the event
;
on *:signal:mouse,leave:{
  echo -s Mouse left window %%window $+ .
}

;        on mouse drag event in @window
;
;    - triggers when the mouse is dragging in a custom window
;
; Params:
;    - %%window -> @window that triggered the event
;    - %%mouse.x -> mouse current x coordinate
;    - %%mouse.x -> mouse current y coordinate
;
on *:signal:mouse,drag:{
  echo -s Mouse is dragging in window %%window at ( $+ %%mouse.x $+ , %%mouse.y $+ ).
}

;        on mouse drop event in @window
;
;    - triggers when a mouse has dropped/done dragging in a custom window
;
; Params:
;    - %%window -> @window that triggered the event
;    - %%mouse.x -> mouse current x coordinate
;    - %%mouse.x -> mouse current y coordinate
;    - %%mouse.origin.x -> mouse drag origin x coordinate
;    - %%mouse.origin.x -> mouse drag origin y coordinate
;
on *:signal:mouse,drop:{
  echo -s Mouse is dropped in window %%window at ( $+ %%mouse.x $+ , %%mouse.y $+ ). $&
    Mouse was dragged from:  ( $+ %%mouse.origin.x $+ , %%mouse.origin.y $+ ).
}

;        on mouse click event in @window
;
;    - triggers when a mouse click occures in a custom window
;
; Params:
;    - %%window -> @window that triggered the event
;    - %%mouse.x -> mouse current x coordinate
;    - %%mouse.x -> mouse current y coordinate
;
on *:signal:mouse,click:{
  echo -s Mouse clicked in window %%window at ( $+ %%mouse.x $+ , %%mouse.y $+ ).
}

;        on mouse double-click event in @window
;
;    - triggers when a double click occures in a custom window
;
; Params:
;    - %%window -> @window that triggered the event
;    - %%mouse.x -> mouse current x coordinate
;    - %%mouse.x -> mouse current y coordinate
;
on *:signal:mouse,dclick:{
  echo -s Mouse double-clicked in window %%window at ( $+ %%mouse.x $+ , %%mouse.y $+ ).
}








/* event dispatcher
*/
menu @* {
  mouse:setcoords | if ($isdragged) .signal -n mouse,drag | else .signal -n mouse,move | .signal -n __enter_event
  sclick:setcoords | .signal -n mouse,click
  dclick:setcoords | .signal -n mouse,dclick
  rclick:setcoords | .signal -n mouse,rclick
  leave:setcoords | .signal -n mouse,leave
}
/*
** set some cross-alias local variables
** This is needed because $mouse.x/y from signal can differ (or not
** exists at all) from the actual window (taken from global pos).
*/
alias setcoords {
  ; mouse x/y
  set -u0 %%mouse.x $mouse.x
  set -u0 %%mouse.y $mouse.y
  ; event/window
  set -u0 %%event $active
  set -u0 %%window $active
}
/*
** check if the mouse is being dragged
*/
alias isdragged {
  if ($mouse.key & 1) {
    .timer $+ %%window -m 0 0 checkdrop $ltimer
    set -u1 %%_x_ $+ %%window $mouse.x
    set -u1 %%_y_ $+ %%window $mouse.y
    return 1
  }
  return 0
}
/*
** check if the mouse is dropped
*/
alias checkdrop {
  if (!$mouse.key) {
    timer $+ $1 off
    set -u0 %%mouse.x $($+(%, %, _x_, $1), 2)
    set -u0 %%mouse.y $($+(%, %, _y_, $1), 2)
    set -u0 %%mouse.origin.x $click($1, $click($1, 0)).x
    set -u0 %%mouse.origin.y $click($1, $click($1, 0)).y
    .signal -n mouse,drop
  }
}
/*
** check if we are within a certain area
*/
alias mouse_enter {
  if ($0 != 4) { echo -sc info * on mouse_enter: syntax error! | halt }
  if ($inrect(%%mouse.x, %%mouse.y, $1, $2, $3, $4)) {
    return __enter_event
  }
  return __enter_nop
}

The example above is very clean (keeps no global variables or data of any kind) and uses a single self-terminating timer per window for the drag/drop event.

Note, my code does not reflect exactly what you want because it’s just a simple example. The same thing done using my custom mouse_enter event can be done to another mouse_leave event without much trouble.

Last edited by Wiz126; 30/11/11 05:13 PM.