1 #include <Application.h>
2 #include <View.h>
3 #include <Window.h>
4
5 #include <stdio.h>
6
7 class view : public BView {
8 public:
view(BRect rect)9 view(BRect rect)
10 : BView(rect, "test view", B_FOLLOW_ALL_SIDES, B_WILL_DRAW)
11 {
12 }
13
14 virtual void
MouseDown(BPoint where)15 MouseDown(BPoint where)
16 {
17 printf("Mouse DOWN !!! %" B_PRIdBIGTIME "\n", system_time());
18
19 BPoint mouseWhere;
20 uint32 buttons;
21 do {
22 GetMouse(&mouseWhere, &buttons);
23 snooze(10000);
24 } while (buttons != 0);
25
26 printf("Mouse UP !!! %" B_PRIdBIGTIME "\n", system_time());
27 }
28 };
29
30
31 class window : public BWindow {
32 public:
window()33 window() :
34 BWindow(BRect(100, 100, 400, 300), "test window", B_DOCUMENT_WINDOW, B_QUIT_ON_WINDOW_CLOSE)
35 {
36 AddChild(new view(Bounds()));
37 }
38
39 virtual void
DispatchMessage(BMessage * message,BHandler * handler)40 DispatchMessage(BMessage *message, BHandler *handler)
41 {
42 bigtime_t when;
43 message->FindInt64("when", &when);
44 switch (message->what) {
45 case B_MOUSE_MOVED:
46 printf("B_MOUSE_MOVED: %" B_PRIdBIGTIME "\n", when);
47 break;
48 case B_MOUSE_UP:
49 printf("B_MOUSE_UP: %" B_PRIdBIGTIME "\n", when);
50 break;
51 case B_MOUSE_DOWN:
52 printf("B_MOUSE_DOWN: %" B_PRIdBIGTIME "\n", when);
53 break;
54 default:
55 break;
56 }
57 BWindow::DispatchMessage(message, handler);
58 }
59 };
60
61 int
main()62 main()
63 {
64 BApplication app("application/x-vnd.getmousetest");
65
66 (new window())->Show();
67
68 app.Run();
69 }
70