* Use the proper channels for reloading. (Added BWebView/BWebPage::Reload().)
* Catch B_RETURN key down messages, when the target is the URL text view. Don't let the text view send a message, but react on B_RETURN only, in the window, also letting the Go button flash for a bonus. This fixes unprovoked (re-)loading of pages when the text control went out of focus and thought the text had changed, sending GOTO_URL. This could happen when just grabbing the scrollbar so that the text control looses focus. Also makes the m_loadedURL string superfluous, which I added for the same purpose. git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@232 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
@@ -151,11 +151,11 @@ LauncherWindow::LauncherWindow(BRect frame, const BMessenger& downloadListener,
|
|||||||
m_StopButton->TrimIcon();
|
m_StopButton->TrimIcon();
|
||||||
|
|
||||||
// URL
|
// URL
|
||||||
m_url = new BTextControl("url", "", "", new BMessage(GOTO_URL));
|
m_url = new BTextControl("url", "", "", NULL);
|
||||||
m_url->SetDivider(50.0);
|
m_url->SetDivider(50.0);
|
||||||
|
|
||||||
// Go
|
// Go
|
||||||
BButton* button = new BButton("", "Go", new BMessage(RELOAD));
|
m_goButton = new BButton("", "Go", new BMessage(GOTO_URL));
|
||||||
|
|
||||||
// Status Bar
|
// Status Bar
|
||||||
m_statusText = new BStringView("status", "");
|
m_statusText = new BStringView("status", "");
|
||||||
@@ -201,7 +201,7 @@ LauncherWindow::LauncherWindow(BRect frame, const BMessenger& downloadListener,
|
|||||||
.Add(m_ForwardButton, 1, 0)
|
.Add(m_ForwardButton, 1, 0)
|
||||||
.Add(m_StopButton, 2, 0)
|
.Add(m_StopButton, 2, 0)
|
||||||
.Add(m_url, 3, 0)
|
.Add(m_url, 3, 0)
|
||||||
.Add(button, 4, 0)
|
.Add(m_goButton, 4, 0)
|
||||||
.SetInsets(kInsetSpacing, kInsetSpacing, kInsetSpacing, kInsetSpacing)
|
.SetInsets(kInsetSpacing, kInsetSpacing, kInsetSpacing, kInsetSpacing)
|
||||||
)
|
)
|
||||||
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
|
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
|
||||||
@@ -223,6 +223,8 @@ LauncherWindow::LauncherWindow(BRect frame, const BMessenger& downloadListener,
|
|||||||
} else {
|
} else {
|
||||||
m_BackButton = 0;
|
m_BackButton = 0;
|
||||||
m_ForwardButton = 0;
|
m_ForwardButton = 0;
|
||||||
|
m_StopButton = 0;
|
||||||
|
m_goButton = 0;
|
||||||
m_url = 0;
|
m_url = 0;
|
||||||
m_menuBar = 0;
|
m_menuBar = 0;
|
||||||
m_statusText = 0;
|
m_statusText = 0;
|
||||||
@@ -253,6 +255,27 @@ LauncherWindow::~LauncherWindow()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LauncherWindow::DispatchMessage(BMessage* message, BHandler* target)
|
||||||
|
{
|
||||||
|
if (m_url && message->what == B_KEY_DOWN && target == m_url->TextView()) {
|
||||||
|
// Handle B_RETURN in the URL text control. This is the easiest
|
||||||
|
// way to react *only* when the user presses the return key in the
|
||||||
|
// address bar, as opposed to trying to load whatever is in there when
|
||||||
|
// the text control just goes out of focus.
|
||||||
|
const char* bytes;
|
||||||
|
if (message->FindString("bytes", &bytes) == B_OK
|
||||||
|
&& bytes[0] == B_RETURN) {
|
||||||
|
// Do it in such a way that the user sees the Go-button go down.
|
||||||
|
m_goButton->SetValue(B_CONTROL_ON);
|
||||||
|
UpdateIfNeeded();
|
||||||
|
m_goButton->Invoke();
|
||||||
|
snooze(1000);
|
||||||
|
m_goButton->SetValue(B_CONTROL_OFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BWebWindow::DispatchMessage(message, target);
|
||||||
|
}
|
||||||
|
|
||||||
void LauncherWindow::MessageReceived(BMessage* message)
|
void LauncherWindow::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
@@ -265,13 +288,13 @@ void LauncherWindow::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RELOAD:
|
case RELOAD:
|
||||||
CurrentWebView()->LoadURL(m_url->Text());
|
CurrentWebView()->Reload();
|
||||||
break;
|
break;
|
||||||
case GOTO_URL: {
|
case GOTO_URL: {
|
||||||
BString url = m_url->Text();
|
BString url;
|
||||||
message->FindString("url", &url);
|
if (message->FindString("url", &url) != B_OK)
|
||||||
if (m_loadedURL != url)
|
url = m_url->Text();
|
||||||
CurrentWebView()->LoadURL(url.String());
|
CurrentWebView()->LoadURL(url.String());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GO_BACK:
|
case GO_BACK:
|
||||||
@@ -502,8 +525,6 @@ void LauncherWindow::LoadCommitted(const BString& url, BWebView* view)
|
|||||||
if (view != CurrentWebView())
|
if (view != CurrentWebView())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_loadedURL = url;
|
|
||||||
|
|
||||||
// This hook is invoked when the load is commited.
|
// This hook is invoked when the load is commited.
|
||||||
if (m_url)
|
if (m_url)
|
||||||
m_url->SetText(url.String());
|
m_url->SetText(url.String());
|
||||||
@@ -542,7 +563,6 @@ void LauncherWindow::LoadFinished(const BString& url, BWebView* view)
|
|||||||
if (view != CurrentWebView())
|
if (view != CurrentWebView())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_loadedURL = url;
|
|
||||||
BString status(url);
|
BString status(url);
|
||||||
status << " finished.";
|
status << " finished.";
|
||||||
StatusChanged(status, view);
|
StatusChanged(status, view);
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ public:
|
|||||||
ToolbarPolicy = HaveToolbar);
|
ToolbarPolicy = HaveToolbar);
|
||||||
virtual ~LauncherWindow();
|
virtual ~LauncherWindow();
|
||||||
|
|
||||||
|
virtual void DispatchMessage(BMessage* message, BHandler* target);
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
virtual void MenusBeginning();
|
virtual void MenusBeginning();
|
||||||
@@ -102,8 +103,8 @@ private:
|
|||||||
IconButton* m_BackButton;
|
IconButton* m_BackButton;
|
||||||
IconButton* m_ForwardButton;
|
IconButton* m_ForwardButton;
|
||||||
IconButton* m_StopButton;
|
IconButton* m_StopButton;
|
||||||
|
BButton* m_goButton;
|
||||||
BTextControl* m_url;
|
BTextControl* m_url;
|
||||||
BString m_loadedURL;
|
|
||||||
BStringView* m_statusText;
|
BStringView* m_statusText;
|
||||||
BStatusBar* m_loadingProgressBar;
|
BStatusBar* m_loadingProgressBar;
|
||||||
BLayoutItem* m_findGroup;
|
BLayoutItem* m_findGroup;
|
||||||
|
|||||||
Reference in New Issue
Block a user