findTextBox_.addKeyUpHandler(new KeyUpHandler() {
@Override
public void onKeyUp(KeyUpEvent event)
{
WindowEx contentWindow = getContentWindow();
if (contentWindow != null)
{
// escape or tab means exit find mode and put focus
// into the main content window
if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE ||
event.getNativeKeyCode() == KeyCodes.KEY_TAB)
{
event.preventDefault();
event.stopPropagation();
if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE)
clearTerm();
contentWindow.focus();
}
else
{
// prevent two enter keys in rapid succession from
// minimizing or maximizing the help pane
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
{
event.preventDefault();
event.stopPropagation();
}
// check for term
String term = findTextBox_.getValue().trim();
// if there is a term then search for it
if (term.length() > 0)
{
// make buttons visible
setButtonVisibility(true);
// perform the find (check for incremental)
if (isIncrementalFindSupported())
{
boolean incremental =
!event.isAnyModifierKeyDown() &&
(event.getNativeKeyCode() != KeyCodes.KEY_ENTER);
performFind(term, true, incremental);
}
else
{
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
performFind(term, true, false);
}
}
// no term means clear term and remove selection
else
{
if (isIncrementalFindSupported())
{
clearTerm();
contentWindow.removeSelection();
}
}
}
}
}