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:
Stephan Aßmus 2005-05-16 11:59:42 +00:00
parent dcf0c6ebd6
commit d557af5b96
2 changed files with 23 additions and 15 deletions

View File

@ -970,6 +970,9 @@ BView::KeyDown(const char* bytes, int32 numBytes)
{
// HOOK function
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,
// will there really be no other view with focus? No
// cycling to the next one?
BView *focus = owner->CurrentFocus();
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
owner->fFocus = this;
owner->SetPreferredHandler(this);
} else {
// we want to unfocus this view, but only if it actually has focus
BView *focus = owner->CurrentFocus();
if (focus == this) {
owner->fFocus = NULL;
owner->SetPreferredHandler(NULL);
@ -3326,6 +3332,10 @@ BView::MoveTo(float x, float y)
originX = x;
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.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);
}

View File

@ -919,6 +919,8 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
}
case B_VIEW_MOVED:
{
// NOTE: This message only arrives if the
// view has flags B_FRAME_EVENTS
BPoint where;
int32 token = B_NULL_TOKEN;
BView *view;
@ -931,7 +933,6 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
if (view)
{
STRACE(("Calling BView(%s)::FrameMoved( %f, %f )\n", view->Name(), where.x, where.y));
// TODO: only if B_FRAME_EVENTS, no?
view->FrameMoved( where );
}
else
@ -941,6 +942,8 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
}
case B_VIEW_RESIZED:
{
// NOTE: This message only arrives if the
// view has flags B_FRAME_EVENTS
float newWidth,
newHeight;
BPoint where;
@ -956,7 +959,6 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
view = findView(top_view, token);
if (view){
STRACE(("Calling BView(%s)::FrameResized( %f, %f )\n", view->Name(), newWidth, newHeight));
// TODO: only if B_FRAME_EVENTS, no?
view->FrameResized( newWidth, newHeight );
}
else
@ -2580,24 +2582,14 @@ void BWindow::setFocus(BView *focusView, bool notifyInputServer)
if (previousFocus == focusView)
return;
fFocus = NULL;
if (previousFocus != NULL)
previousFocus->Invalidate();
fFocus = focusView;
if (focusView != NULL)
focusView->Invalidate();
if (focusView)
focusView->MakeFocus(true);
// TODO: find out why do we have to notify input server.
if (notifyInputServer)
{
// 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!!!!
// TODO: Not correct, only Option-Tab should be handled here.
if ( key == B_TAB)
{
BView *nextFocus;