Move the view when hitting the space key. This shows that GLView in direct
mode can't correctly handle the view being moved.
This commit is contained in:
@@ -18,6 +18,7 @@ public:
|
|||||||
virtual void AttachedToWindow(void);
|
virtual void AttachedToWindow(void);
|
||||||
virtual void FrameResized(float newWidth, float newHeight);
|
virtual void FrameResized(float newWidth, float newHeight);
|
||||||
virtual void MessageReceived(BMessage * msg);
|
virtual void MessageReceived(BMessage * msg);
|
||||||
|
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||||
|
|
||||||
void Render(void);
|
void Render(void);
|
||||||
|
|
||||||
@@ -132,6 +133,7 @@ void SampleGLView::AttachedToWindow(void)
|
|||||||
gInit();
|
gInit();
|
||||||
gReshape(width, height);
|
gReshape(width, height);
|
||||||
UnlockGL();
|
UnlockGL();
|
||||||
|
MakeFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -247,7 +249,24 @@ void SampleGLView::MessageReceived(BMessage * msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SampleGLView::KeyDown(const char *bytes, int32 numBytes)
|
||||||
|
{
|
||||||
|
static bool moved = false;
|
||||||
|
switch (bytes[0]) {
|
||||||
|
case B_SPACE:
|
||||||
|
if (moved) {
|
||||||
|
MoveBy(-30, -30);
|
||||||
|
moved = false;
|
||||||
|
} else {
|
||||||
|
MoveBy(30, 30);
|
||||||
|
moved = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
BView::KeyDown(bytes, numBytes);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user