Home | Trees | Indices | Help |
|
---|
|
1 """ Control Widgets. Presently comprises a Vertical Slider and derivatives. 2 3 HorizontalSlider and HorizontalSlider2 added by Bill Winder 4 AreaSlider and AreaSlider2 added by Bill Winder 5 6 Copyright (C) 2008, 2009, 2010 Luke Kenneth Casson Leighton <lkcl@lkcl.net> 7 Copyright (C) 2010 - Cedric Gestes <gestes@aldebaran-robotics.com> 8 Copyright (C) 2009, 2010 - Bill Winder <wgwinder@gmail.com> 9 10 11 To do: All controls with draggable=True do not fire the OnFocus methon on single click. 12 the control does not activate the OnFocus method. Clicking the handle does fire OnFocus, however. 13 14 """ 15 16 from pyjamas import Factory 17 from pyjamas import DOM 18 from pyjamas.ui import KeyboardListener 19 from pyjamas.ui.TextBox import TextBox 20 from pyjamas.ui.Control import Control 21 222467 68 Factory.registerClass('pyjamas.ui.InputControl', 'InputControl', InputControl) 6927 28 if not kwargs.has_key("StyleName"): 29 kwargs['StyleName'] = "gwt-InputControl" 30 self.input = TextBox() 31 self.input.addKeyboardListener(self) 32 #element = DOM.createDiv() 33 if kwargs.has_key('Element'): 34 # XXX FIXME: unlikely to work! 35 element = kwargs.pop('Element') 36 else: 37 element = self.input.getElement() # YUK!!! 38 Control.__init__(self, element, min_value, max_value, start_value, step, 39 **kwargs) 40 41 self.addClickListener(self) 42 self.addFocusListener(self) 43 self.addKeyboardListener(self)4446 self.addStyleName("gwt-InputControl-focussed")4749 self.removeStyleName("gwt-InputControl-focussed")50 5456 if keycode == KeyboardListener.KEY_ENTER: 57 DOM.eventPreventDefault(DOM.eventGetCurrentEvent()) 58 txt = self.input.getText() 59 if not txt: 60 return 61 new_value = float(txt) 62 new_value = self.processValue(new_value) 63 self.setControlPos(new_value) 64 self.setValue(new_value) 65 else: 66 Control.onKeyPress(self, sender, keycode, modifiers)
Home | Trees | Indices | Help |
|
---|
http://epydoc.sourceforge.net |