Skip to content

Commit

Permalink
Removed some calls to ForceKillFocus() that are no longer needed sinc…
Browse files Browse the repository at this point in the history
…e the

reference display frame is loaded with Javascript rather than with OpenURI().

M    gui/reference_display_frame.py
M    search/searchpanel.py
M    guess_verse.py


git-svn-id: https://bpbible.googlecode.com/svn/trunk@1320 20523bf7-2b47-0410-960a-a116b6c96ec9
  • Loading branch information
jonmmorgan committed Jun 5, 2011
1 parent 9bba540 commit 5ac0b2d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
11 changes: 6 additions & 5 deletions guess_verse.py
@@ -1,4 +1,3 @@
from gui.reference_display_frame import ReferenceDisplayFrame
from backend.verse_template import VerseTemplate
from backend.bibleinterface import biblemgr
from xrc.guess_verse_xrc import xrcGuessVerseFrame
Expand All @@ -11,6 +10,12 @@ class GuessVerseFrame(xrcGuessVerseFrame):
def __init__(self, parent):
super(GuessVerseFrame, self).__init__(parent)

# This call makes sure that the reference display frame is loaded
# with an empty reference.
# This means that all future references displayed will be shown with
# Javascript, and so there won't be any focus bugs.
self.reference_frame.RefreshUI()

self.reference_frame.template = VerseTemplate(
body=u"$text", headings=""
)
Expand All @@ -29,11 +34,7 @@ def new_guess(self):
randomnum = random.randint(1, 31102)
self.key = VK("Gen 1:%d" % randomnum)
self.user_key = UserVK(self.key)
item_to_focus_on = wx.Window.FindFocus()
self.reference_frame.SetReference(self.key.getText())
# Force focus to remain on the correct control after setting the reference.
self.reference_frame.ForceKillFocus()
item_to_focus_on.SetFocus()

def on_show_answer(self, event):
Tooltip.do_not_show_tooltip = True
Expand Down
4 changes: 2 additions & 2 deletions gui/reference_display_frame.py
Expand Up @@ -27,8 +27,8 @@ def SetReference(self, reference, *args, **kwargs):
if self.reference or old_reference:
self._RefreshUI(*args, **kwargs)

def RefreshUI(self, event):
if not event.settings_changed:
def RefreshUI(self, event=None):
if event and not event.settings_changed:
return
self._RefreshUI()

Expand Down
7 changes: 0 additions & 7 deletions search/searchpanel.py
Expand Up @@ -174,7 +174,6 @@ def __init__(self, parent):
self.stop = False
self.regexes = []
self.fields = []
self.do_not_grab_focus = False

# if search panel is on screen at startup, on_show and set_version will
# both be called. Then if there is no index, it will prompt twice.
Expand Down Expand Up @@ -202,11 +201,6 @@ def on_create(self, event=None):
def on_list(self, event):
item_text = self.verselist.results[event.m_itemIndex]
self.versepreview.SetReference(item_text)
if self.do_not_grab_focus:
self.do_not_grab_focus = False
else:
self.verselist.SetFocus()
self.versepreview.ForceKillFocus()

def search_and_show(self, key="", version=None):
self.searchkey.SetValue(key)
Expand Down Expand Up @@ -399,7 +393,6 @@ def next_search_result(self, offset):
elif index == item_count:
index = 0

self.do_not_grab_focus = True
self.verselist.SetSelection(index)
self.verselist.EnsureVisible(index)
self.go_to_reference(index)
Expand Down

0 comments on commit 5ac0b2d

Please sign in to comment.