Php/docs/function.ncurses-getmouse

来自菜鸟教程
跳转至:导航、​搜索

ncurses_getmouse

(PHP 4 >= 4.2.0, PHP 5 < 5.3.0, PECL ncurses >= 1.0.0)

ncurses_getmouseReads mouse event


说明

ncurses_getmouse ( array &$mevent ) : bool

Warning 此函数是实验性的。此函数的表象,包括名称及其相关文档都可能在未来的 PHP 发布版本中未通知就被修改。使用本函数风险自担。


ncurses_getmouse() reads mouse event out of queue.


参数

mevent

Event options will be delivered in this parameter which has to be an array, passed by reference (see example below).

On success an associative array with following keys will be delivered:

  • "id" : Id to distinguish multiple devices

  • "x" : screen relative x-position in character cells

  • "y" : screen relative y-position in character cells

  • "z" : currently not supported

  • "mmask" : Mouse action


返回值

Returns false if a mouse event is actually visible in the given window, otherwise returns true.


范例

Example #1 ncurses_getmouse() example

<?phpswitch (ncurses_getch()){  case NCURSES_KEY_MOUSE:    if (!ncurses_getmouse($mevent)){      if ($mevent["mmask"] & NCURSES_MOUSE_BUTTON1_PRESSED){        $mouse_x = $mevent["x"]; // Save mouse position        $mouse_y = $mevent["y"];      }    }  break;  default:    /* .... */}?>

参见