comparison browser_side/dialog.py @ 43:a7ff1e6f1229

browser_side: prevent default for escape key (cancel HTTPRequest in FF)
author Goffi <goffi@goffi.org>
date Wed, 25 May 2011 14:21:48 +0200
parents 71a9cc9b9d57
children 153de5d461a4
comparison
equal deleted inserted replaced
42:71a9cc9b9d57 43:a7ff1e6f1229
19 along with this program. If not, see <http://www.gnu.org/licenses/>. 19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 """ 20 """
21 21
22 from pyjamas.ui.VerticalPanel import VerticalPanel 22 from pyjamas.ui.VerticalPanel import VerticalPanel
23 from pyjamas.ui.HorizontalPanel import HorizontalPanel 23 from pyjamas.ui.HorizontalPanel import HorizontalPanel
24 from pyjamas.ui.PopupPanel import PopupPanel
24 from pyjamas.ui.DialogBox import DialogBox 25 from pyjamas.ui.DialogBox import DialogBox
25 from pyjamas.ui.ListBox import ListBox 26 from pyjamas.ui.ListBox import ListBox
26 from pyjamas.ui.Button import Button 27 from pyjamas.ui.Button import Button
27 from pyjamas.ui.HTML import HTML 28 from pyjamas.ui.HTML import HTML
29 from pyjamas.ui.KeyboardListener import KEY_ESCAPE
28 30
29 class ContactsChooser(DialogBox): 31 class ContactsChooser(DialogBox):
30 32
31 def __init__(self, host, callback, nb_contact=None, text='Please select contacts'): 33 def __init__(self, host, callback, nb_contact=None, text='Please select contacts'):
32 """ 34 """
128 130
129 def onClose(self): 131 def onClose(self):
130 self.hide() 132 self.hide()
131 if self.callback: 133 if self.callback:
132 self.callback() 134 self.callback()
135
136 class PopupPanelWrapper(PopupPanel):
137 """This wrapper catch Escape event to avoid request cancellation by Firefox"""
138
139 def onEventPreview(self, event):
140 if event.type in ["keydown", "keypress", "keyup"] and event.keyCode == KEY_ESCAPE:
141 #needed to prevent request cancellation in Firefox
142 event.preventDefault()
143 return PopupPanel.onEventPreview(self, event)