Project

Profile

Help

Revision 3541bd46

Added by Vincent Le Goff over 4 years ago

When focusing the input, go to the end of it

View differences:

src/ui/window.py
171 171
        # Ouput
172 172
        l_output = wx.StaticText(self, -1, t("ui.client.output"))
173 173
        t_output = wx.TextCtrl(self, -1, "",
174
                size=(600, 400), style=wx.TE_MULTILINE|wx.TE_READONLY)
174
                size=(600, 400), style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_PROCESS_TAB)
175 175
        self.output = t_output
176 176

  
177 177
        # Add the output fields in the sizer
......
183 183
        t_password.Bind(wx.EVT_TEXT_ENTER, self.EvtText)
184 184
        self.Bind(EVT_FOCUS, self.OnFocus)
185 185
        t_input.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
186
        t_input.Bind(wx.EVT_SET_FOCUS, self.OnInputFocused)
186 187
        t_password.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
187 188
        t_output.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
188 189

  
......
216 217
            self.password.SetFocus()
217 218
            self.input.Hide()
218 219

  
220
    def OnInputFocused(self, e):
221
        """Input gains the focus."""
222
        message = self.input.GetValue()
223
        if message:
224
            self.input.SetInsertionPoint(len(message) + 1)
225
        e.Skip()
226

  
219 227
    def OnKeyDown(self, e):
220 228
        """A key is pressed in the window."""
221 229
        skip = True
......
232 240
            if code == (key, modifiers):
233 241
                macro.execute(self.engine, self.client)
234 242

  
235
        if not modifiers and e.GetEventObject() is self.output:
243
        if e.GetEventObject() is self.output:
236 244
            shortcut = key_name(key, modifiers)
237 245
            if shortcut:
238
                print "Trying to redirect...", shortcut
239
            if shortcut and len(shortcut) == 1:
240
                self.input.AppendText(shortcut.lower())
241
                self.input.SetFocus()
242
            elif shortcut == "Backspace":
243
                message = self.input.GetValue()
244
                if message:
245
                    message = message[:-1]
246
                    self.input.SetValue(message)
247
                self.input.SetFocus()
248
                self.input.SetInsertionPoint(len(message) + 1)
249
        elif skip:
246
                if len(shortcut) == 1:
247
                    self.input.AppendText(shortcut.lower())
248
                    self.input.SetFocus()
249
                elif shortcut.startswith("Shift + ") and len(shortcut) == 9:
250
                    self.input.AppendText(shortcut[8])
251
                    self.input.SetFocus()
252
                elif shortcut == "Backspace":
253
                    message = self.input.GetValue()
254
                    if message:
255
                        message = message[:-1]
256
                        self.input.SetValue(message)
257
                    self.input.SetFocus()
258
                    self.input.SetInsertionPoint(len(message) + 1)
259
        elif e.GetEventObject() == self.input:
260
            if key == wx.WXK_TAB:
261
                pass
262

  
263
        if skip:
250 264
            e.Skip()
251 265

  
252 266
    def HandleHistory(self, modifiers, key):

Also available in: Unified diff