Fixes to my fixes of BView::MakeFocus(), the previous focus BView needs to be unfocused of course so the derived classes implementation gets called. Simplified BWindow::setFocus(). BView calls FrameResized() and FrameMoved() if it has no parent, I don't know how R5 handles it, but I added a TODO...
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12683 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -970,6 +970,9 @@ BView::KeyDown(const char* bytes, int32 numBytes)
|
|||||||
{
|
{
|
||||||
// HOOK function
|
// HOOK function
|
||||||
STRACE(("\tHOOK: BView(%s)::KeyDown()\n", Name()));
|
STRACE(("\tHOOK: BView(%s)::KeyDown()\n", Name()));
|
||||||
|
if (numBytes > 0 && bytes[0] == B_TAB) {
|
||||||
|
// TODO: handle tab navigation here instead of in BWindow
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1243,13 +1246,16 @@ BView::MakeFocus(bool focusState)
|
|||||||
// TODO: If this view has focus and focusState==false,
|
// TODO: If this view has focus and focusState==false,
|
||||||
// will there really be no other view with focus? No
|
// will there really be no other view with focus? No
|
||||||
// cycling to the next one?
|
// cycling to the next one?
|
||||||
|
BView *focus = owner->CurrentFocus();
|
||||||
if (focusState) {
|
if (focusState) {
|
||||||
|
// Unfocus a previous focus view
|
||||||
|
if (focus && focus != this)
|
||||||
|
focus->MakeFocus(false);
|
||||||
// if we want to make this view the current focus view
|
// if we want to make this view the current focus view
|
||||||
owner->fFocus = this;
|
owner->fFocus = this;
|
||||||
owner->SetPreferredHandler(this);
|
owner->SetPreferredHandler(this);
|
||||||
} else {
|
} else {
|
||||||
// we want to unfocus this view, but only if it actually has focus
|
// we want to unfocus this view, but only if it actually has focus
|
||||||
BView *focus = owner->CurrentFocus();
|
|
||||||
if (focus == this) {
|
if (focus == this) {
|
||||||
owner->fFocus = NULL;
|
owner->fFocus = NULL;
|
||||||
owner->SetPreferredHandler(NULL);
|
owner->SetPreferredHandler(NULL);
|
||||||
@@ -3326,6 +3332,10 @@ BView::MoveTo(float x, float y)
|
|||||||
|
|
||||||
originX = x;
|
originX = x;
|
||||||
originY = y;
|
originY = y;
|
||||||
|
// TODO: investigate R5 behaviour for unattached views
|
||||||
|
// maybe the message is generated, but postponed until the view is added
|
||||||
|
if (!owner && fFlags & B_FRAME_EVENTS)
|
||||||
|
FrameMoved(BPoint(originX, originY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3364,6 +3374,11 @@ BView::ResizeTo(float width, float height)
|
|||||||
|
|
||||||
fBounds.right = fBounds.left + width;
|
fBounds.right = fBounds.left + width;
|
||||||
fBounds.bottom = fBounds.top + height;
|
fBounds.bottom = fBounds.top + height;
|
||||||
|
|
||||||
|
// TODO: investigate R5 behaviour for unattached views
|
||||||
|
// maybe the message is generated, but postponed until the view is added
|
||||||
|
if (!owner && fFlags & B_FRAME_EVENTS)
|
||||||
|
FrameResized(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -919,6 +919,8 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
|
|||||||
}
|
}
|
||||||
case B_VIEW_MOVED:
|
case B_VIEW_MOVED:
|
||||||
{
|
{
|
||||||
|
// NOTE: This message only arrives if the
|
||||||
|
// view has flags B_FRAME_EVENTS
|
||||||
BPoint where;
|
BPoint where;
|
||||||
int32 token = B_NULL_TOKEN;
|
int32 token = B_NULL_TOKEN;
|
||||||
BView *view;
|
BView *view;
|
||||||
@@ -931,7 +933,6 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
|
|||||||
if (view)
|
if (view)
|
||||||
{
|
{
|
||||||
STRACE(("Calling BView(%s)::FrameMoved( %f, %f )\n", view->Name(), where.x, where.y));
|
STRACE(("Calling BView(%s)::FrameMoved( %f, %f )\n", view->Name(), where.x, where.y));
|
||||||
// TODO: only if B_FRAME_EVENTS, no?
|
|
||||||
view->FrameMoved( where );
|
view->FrameMoved( where );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -941,6 +942,8 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
|
|||||||
}
|
}
|
||||||
case B_VIEW_RESIZED:
|
case B_VIEW_RESIZED:
|
||||||
{
|
{
|
||||||
|
// NOTE: This message only arrives if the
|
||||||
|
// view has flags B_FRAME_EVENTS
|
||||||
float newWidth,
|
float newWidth,
|
||||||
newHeight;
|
newHeight;
|
||||||
BPoint where;
|
BPoint where;
|
||||||
@@ -956,7 +959,6 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
|
|||||||
view = findView(top_view, token);
|
view = findView(top_view, token);
|
||||||
if (view){
|
if (view){
|
||||||
STRACE(("Calling BView(%s)::FrameResized( %f, %f )\n", view->Name(), newWidth, newHeight));
|
STRACE(("Calling BView(%s)::FrameResized( %f, %f )\n", view->Name(), newWidth, newHeight));
|
||||||
// TODO: only if B_FRAME_EVENTS, no?
|
|
||||||
view->FrameResized( newWidth, newHeight );
|
view->FrameResized( newWidth, newHeight );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -2580,24 +2582,14 @@ void BWindow::setFocus(BView *focusView, bool notifyInputServer)
|
|||||||
if (previousFocus == focusView)
|
if (previousFocus == focusView)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fFocus = NULL;
|
if (focusView)
|
||||||
|
focusView->MakeFocus(true);
|
||||||
if (previousFocus != NULL)
|
|
||||||
previousFocus->Invalidate();
|
|
||||||
|
|
||||||
fFocus = focusView;
|
|
||||||
|
|
||||||
if (focusView != NULL)
|
|
||||||
focusView->Invalidate();
|
|
||||||
|
|
||||||
// TODO: find out why do we have to notify input server.
|
// TODO: find out why do we have to notify input server.
|
||||||
if (notifyInputServer)
|
if (notifyInputServer)
|
||||||
{
|
{
|
||||||
// what am I suppose to do here??
|
// what am I suppose to do here??
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: find out why R5 does this
|
|
||||||
SetPreferredHandler(fFocus);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -2706,6 +2698,7 @@ bool BWindow::handleKeyDown( const char key, uint32 modifiers){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Keyboard navigation through views!!!!
|
// Keyboard navigation through views!!!!
|
||||||
|
// TODO: Not correct, only Option-Tab should be handled here.
|
||||||
if ( key == B_TAB)
|
if ( key == B_TAB)
|
||||||
{
|
{
|
||||||
BView *nextFocus;
|
BView *nextFocus;
|
||||||
|
|||||||
Reference in New Issue
Block a user