#include #include #include #include class view : public BView { public: view(BRect rect) : BView(rect, "test view", B_FOLLOW_ALL_SIDES, B_WILL_DRAW) { } virtual void MouseDown(BPoint where) { printf("Mouse DOWN !!! %" B_PRIdBIGTIME "\n", system_time()); BPoint mouseWhere; uint32 buttons; do { GetMouse(&mouseWhere, &buttons); snooze(10000); } while (buttons != 0); printf("Mouse UP !!! %" B_PRIdBIGTIME "\n", system_time()); } }; class window : public BWindow { public: window() : BWindow(BRect(100, 100, 400, 300), "test window", B_DOCUMENT_WINDOW, B_QUIT_ON_WINDOW_CLOSE) { AddChild(new view(Bounds())); } virtual void DispatchMessage(BMessage *message, BHandler *handler) { bigtime_t when; message->FindInt64("when", &when); switch (message->what) { case B_MOUSE_MOVED: printf("B_MOUSE_MOVED: %" B_PRIdBIGTIME "\n", when); break; case B_MOUSE_UP: printf("B_MOUSE_UP: %" B_PRIdBIGTIME "\n", when); break; case B_MOUSE_DOWN: printf("B_MOUSE_DOWN: %" B_PRIdBIGTIME "\n", when); break; default: break; } BWindow::DispatchMessage(message, handler); } }; int main() { BApplication app("application/x-vnd.getmousetest"); (new window())->Show(); app.Run(); }