In webcontrol.h, add the following methods to wxWebControl:
- Code: Select all
bool CanGoForward() const;
bool CanGoBack() const;
In webcontrol.cpp, add the method implementations:
- Code: Select all
// (METHOD) wxWebControl::CanGoForward
// Description: Returns true if it is possible to navigate forward,
// and false otherwise.
//
// Syntax: bool wxWebControl::CanGoForward()
//
// Remarks:
//
// Returns: True if it is possible to navigate forward
bool wxWebControl::CanGoForward() const
{
PRBool canGoForward;
m_ptrs->m_web_navigation->GetCanGoForward(&canGoForward);
return (canGoForward == PR_TRUE);
}
// (METHOD) wxWebControl::CanGoBackward
// Description: Returns true if it is possible to navigate backward,
// and false otherwise.
//
// Syntax: bool wxWebControl::CanGoBackward()
//
// Remarks:
//
// Returns: True if it is possible to navigate backward
bool wxWebControl::CanGoBack() const
{
PRBool canGoBackward;
m_ptrs->m_web_navigation->GetCanGoBack(&canGoBackward);
return (canGoBackward == PR_TRUE);
}
Probably the best place to use this is the application's wxEVT_WEB_LOCATIONCHANGE event handler, e.g.:
- Code: Select all
void BrowserWindow::onLocationChange(wxWebEvent& event)
{
browserToolBar->EnableTool(wxID_BACKWARD, webControl->CanGoBack());
browserToolBar->EnableTool(wxID_FORWARD, webControl->CanGoForward());
browserToolBar->Refresh();
}
The refresh at the end of the event handler is because the wxAUIToolBar wasn't refreshing automatically.
Hans