keydown event with a read only multiline field

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

keydown event with a read only multiline field

Nathan Smith
Hi there,

I am designing an application which has two side-by-side multiline text
fields.

The left is input, the right is output.

the left is read and write, the right is read only.

I would like it so that if a typable character, IE any letter, number,
or symbol was typed in the read only box, it would take that symbol,
append it to the read write box, and then set focus to the read write box.

However, I would like it so that arrow keys would not affect this.

So far, the event for changed text seems the way to go, however, I am
unable to identify a way to tell when it is the user typing, verses,
when it is the computer appending text.

Any help on this matter would be appreciated.

Thanks

Nate

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: keydown event with a read only multiline field

johnf


On 4/2/19 5:44 PM, Nathan smith wrote:
Hi there,

I am designing an application which has two side-by-side multiline text fields.

The left is input, the right is output.

the left is read and write, the right is read only.

I would like it so that if a typable character, IE any letter, number, or symbol was typed in the read only box, it would take that symbol, append it to the read write box, and then set focus to the read write box.

However, I would like it so that arrow keys would not affect this.

So far, the event for changed text seems the way to go, however, I am unable to identify a way to tell when it is the user typing, verses, when it is the computer appending text.

Any help on this matter would be appreciated.

Thanks

Nate


I had a similar request.  The problem I ran into was with the  readonly textcontrl.  When it is set to readonly the key stokes are not active.  So I had to simulate the readonly and capture the keystrokes.  Make sure you account for the different platforms.

def OnChar(self, event):

    keycode = event.GetUnicodeKey()

    if keycode != wx.WXK_NONE:

        # It's a printable character
        wx.LogMessage("You pressed '%c'"%keycode)

    else:

        # It's a special key, deal with all the known ones:
        if keycode in [wx.WXK_LEFT, wx.WXK_RIGHT]:
            # move cursor ...
            MoveCursor()

        elif keycode == wx.WXK_F1:
            # give help ...
            GiveHelp()

Johnf


--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: keydown event with a read only multiline field

Nathan Smith

Hiya.

Thanks for that, figured I'd have to do something along those lines, just was not sure of how to identify what the key was.

Will that work on MAC as well?

I seem to remember reading an obscure line that that event broke on mac OS.

thanks

Nate

On 03/04/2019 02:45, johnf wrote:


On 4/2/19 5:44 PM, Nathan smith wrote:
Hi there,

I am designing an application which has two side-by-side multiline text fields.

The left is input, the right is output.

the left is read and write, the right is read only.

I would like it so that if a typable character, IE any letter, number, or symbol was typed in the read only box, it would take that symbol, append it to the read write box, and then set focus to the read write box.

However, I would like it so that arrow keys would not affect this.

So far, the event for changed text seems the way to go, however, I am unable to identify a way to tell when it is the user typing, verses, when it is the computer appending text.

Any help on this matter would be appreciated.

Thanks

Nate


I had a similar request.  The problem I ran into was with the  readonly textcontrl.  When it is set to readonly the key stokes are not active.  So I had to simulate the readonly and capture the keystrokes.  Make sure you account for the different platforms.

def OnChar(self, event):

    keycode = event.GetUnicodeKey()

    if keycode != wx.WXK_NONE:

        # It's a printable character
        wx.LogMessage("You pressed '%c'"%keycode)

    else:

        # It's a special key, deal with all the known ones:
        if keycode in [wx.WXK_LEFT, wx.WXK_RIGHT]:
            # move cursor ...
            MoveCursor()

        elif keycode == wx.WXK_F1:
            # give help ...
            GiveHelp()

Johnf


--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: keydown event with a read only multiline field

johnf

I know very  little about Mac and wxPython issues - sorry.

You need to review wx.EVT_CHAR event to first capture the key event.  In my case that was all I needed know - that is that a key stroke occurred.  If you need the actual char code then you will need something like the code I provided which used event.GetUnicodeKey() (that assumes you are using wxPython 4.x)

Johnf

On 4/3/19 3:14 AM, Nathan smith wrote:

Hiya.

Thanks for that, figured I'd have to do something along those lines, just was not sure of how to identify what the key was.

Will that work on MAC as well?

I seem to remember reading an obscure line that that event broke on mac OS.

thanks

Nate

On 03/04/2019 02:45, johnf wrote:


On 4/2/19 5:44 PM, Nathan smith wrote:
Hi there,

I am designing an application which has two side-by-side multiline text fields.

The left is input, the right is output.

the left is read and write, the right is read only.

I would like it so that if a typable character, IE any letter, number, or symbol was typed in the read only box, it would take that symbol, append it to the read write box, and then set focus to the read write box.

However, I would like it so that arrow keys would not affect this.

So far, the event for changed text seems the way to go, however, I am unable to identify a way to tell when it is the user typing, verses, when it is the computer appending text.

Any help on this matter would be appreciated.

Thanks

Nate


I had a similar request.  The problem I ran into was with the  readonly textcontrl.  When it is set to readonly the key stokes are not active.  So I had to simulate the readonly and capture the keystrokes.  Make sure you account for the different platforms.

def OnChar(self, event):

    keycode = event.GetUnicodeKey()

    if keycode != wx.WXK_NONE:

        # It's a printable character
        wx.LogMessage("You pressed '%c'"%keycode)

    else:

        # It's a special key, deal with all the known ones:
        if keycode in [wx.WXK_LEFT, wx.WXK_RIGHT]:
            # move cursor ...
            MoveCursor()

        elif keycode == wx.WXK_F1:
            # give help ...
            GiveHelp()

Johnf


--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.