I have a TextCtrl and i want to add a newline at the end of the pasted text and
i was wondering if it is possible to overwrite the default paste behaviour to achieve this.
I don’t want to bind the same handler on multiple events i just want to overwrite the
default paste behaviour if it is possible. For example on linux you can paste text
using the CTRL + v but you can also use the mouse middle click which does not trigger
the EVT_TEXT_PASTE. In a normal situation i would had to bind the same handler both on
EVT_TEXT_PASTE and on EVT_MIDDLE_DOWN it’s not hard to do but i am just wondering
if i could overwrite the default paste behaviour this way if a new “shortcut” was about to be
added i wouldnt had to make any changes and bind new events.
I have a TextCtrl and i want to add a newline at the end of the pasted
text and
i was wondering if it is possible to overwrite the default paste
behaviour to achieve this.
I don't want to bind the same handler on multiple events i just want to
overwrite the
default paste behaviour if it is possible. For example on linux you can
paste text
using the CTRL + v but you can also use the mouse middle click which
does not trigger
the EVT_TEXT_PASTE. In a normal situation i would had to bind the same
handler both on
EVT_TEXT_PASTE and on EVT_MIDDLE_DOWN it's not hard to do but i am just
wondering
if i could overwrite the default paste behaviour this way if a new
"shortcut" was about to be
added i wouldnt had to make any changes and bind new events.
I'm not quite sure what exactly you are looking for but if you want to change what will be pasted then the normal way to do something like that would be to fetch the data from wx.TheClipboard yourself, modify it and then put it in the textctrl yourself. You could do this from the event handler for the keyboard shortcuts, or anywhere else.
And then overwrite the Paste method like so:
textctrl.Paste = MyPaste
OR
wx.core.TextEntryBase_Paste = MyPaste
Then just by hitting CTRL + v i could basically add a newline because instead of the default Paste method i could use mine.
I am confused with how the Paste occurs. Does the default Paste() method gets called when we hit CTRL + v or does the event
gets handled directly at the wxWidgets (C/C++) level?
···
On Tuesday, March 17, 2015 at 1:04:22 AM UTC+2, ytub...@gmail.com wrote:
Hi everyone
I have a TextCtrl and i want to add a newline at the end of the pasted text and
i was wondering if it is possible to overwrite the default paste behaviour to achieve this.
I don’t want to bind the same handler on multiple events i just want to overwrite the
default paste behaviour if it is possible. For example on linux you can paste text
using the CTRL + v but you can also use the mouse middle click which does not trigger
the EVT_TEXT_PASTE. In a normal situation i would had to bind the same handler both on
EVT_TEXT_PASTE and on EVT_MIDDLE_DOWN it’s not hard to do but i am just wondering
if i could overwrite the default paste behaviour this way if a new “shortcut” was about to be
added i wouldnt had to make any changes and bind new events.
Then just by hitting CTRL + v i could basically add a newline because instead of the default Paste method i could use mine.
I am confused with how the Paste occurs. Does the default Paste() method gets called when we hit CTRL + v or does the event
gets handled directly at the wxWidgets (C/C++) level?
Can you become more specific ?
From the documentation of the wx.lib.masked wxPython API Documentation — wxPython Phoenix 4.2.2 documentation
“allowing characters within a data entry control to remain fixed, and providing fine-grain control over allowed user input.”
I can’t understand how this is going to help me change the default paste behaviour.
Can you give me an example?
I was thinking of the code not the doc, in particular.
wx.lib.masked.textctrl in there look at BaseMaskedTextCtrl.Paste and
at wx.lib.masked.maskededit where the masked specific paste code is
in MaskedEditMixin._Paste.
Werner
Can you become more specific ?
From the documentation of the wx.lib.masked
“allowing characters within a data entry control to remain
fixed, and providing fine-grain control over allowed user
input.”
I can’t understand how this is going to help me change the
default paste behaviour.
Can you give me an example?
I was thinking of the code not the doc, in particular.
wx.lib.masked.textctrl in there look at BaseMaskedTextCtrl.Paste and
at wx.lib.masked.maskededit where the masked specific paste code is
in MaskedEditMixin._Paste.
Werner
Hi, Werner
I found the time and i looked at the code. Correct me if am wrong but in the above code there is an event handler bind on MaskedEditMixin._OnCtrl_V which basically calls the Paste() method.
Hhm, don’t know way Will Sadkin (author of masked) did use the
OnKeyDown handler also for Paste.
I would just give your method a try.
Note that Paste is defined in TextEntry which TextCtrl is
inheriting, maybe that is way Will did it with the OnKeyDown
handler.
Werner