Patch by Wim van der Meer: Use the new get_mouse() function instead of the
previous hack. Thanks a bunch! Closes #6019. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36841 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -9,39 +9,21 @@
|
|||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
|
#include <InterfaceDefs.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <Node.h>
|
#include <Node.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <PopUpMenu.h>
|
#include <PopUpMenu.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <View.h>
|
|
||||||
#include <Window.h>
|
|
||||||
|
|
||||||
|
|
||||||
/*! Returns the current mouse position in screen coordinates.
|
|
||||||
Since there is no method to retrieve this in the Be API without a view,
|
|
||||||
this looks a bit more complicated.
|
|
||||||
*/
|
|
||||||
static BPoint
|
static BPoint
|
||||||
mouse_position()
|
mouse_position()
|
||||||
{
|
{
|
||||||
BWindow* window = new BWindow(BRect(-1000, -1000, -900, -900), "mouse",
|
// Returns the mouse position in screen coordinates
|
||||||
B_NO_BORDER_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
|
||||||
B_AVOID_FRONT | B_AVOID_FOCUS);
|
|
||||||
BView* view = new BView(window->Bounds(), "mouse", B_FOLLOW_ALL, 0);
|
|
||||||
window->AddChild(view);
|
|
||||||
window->Run();
|
|
||||||
|
|
||||||
window->Lock();
|
|
||||||
|
|
||||||
BPoint position;
|
BPoint position;
|
||||||
uint32 buttons;
|
get_mouse(&position, NULL);
|
||||||
view->GetMouse(&position, &buttons);
|
|
||||||
view->ConvertToScreen(&position);
|
|
||||||
|
|
||||||
window->Quit();
|
|
||||||
|
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user