Added a small test for GetMouse().

Looks like that, when called with "true" as third parameter,
it "eats" all the input messages like B_MOUSE_UP/B_MOUSE_MOVED. That means our implementation isn't correct.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12699 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2005-05-17 13:47:30 +00:00
parent 82450360bb
commit 335b47697c
2 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,69 @@
#include <Application.h>
#include <View.h>
#include <Window.h>
#include <stdio.h>
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 !!! %lld\n", system_time());
BPoint mouseWhere;
ulong buttons;
do {
GetMouse(&mouseWhere, &buttons);
snooze(10000);
} while (buttons != 0);
printf("Mouse UP !!! %lld\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: %lld\n", when);
break;
case B_MOUSE_UP:
printf("B_MOUSE_UP: %lld\n", when);
break;
case B_MOUSE_DOWN:
printf("B_MOUSE_DOWN: %lld\n", when);
break;
default:
break;
}
BWindow::DispatchMessage(message, handler);
}
};
int
main()
{
BApplication app("application/x-vnd.getmousetest");
(new window())->Show();
app.Run();
}

View File

@ -91,6 +91,11 @@ SimpleTest ScreenTest :
: be
;
SimpleTest GetMouseTest :
GetMouseTest.cpp
: be
;
SEARCH on [ FGristFiles
ScrollView.cpp CheckBox.cpp ChannelSlider.cpp ChannelControl.cpp
] = [ FDirName $(OBOS_TOP) src kits interface ] ;