manual button initiation?

7 views
Skip to first unread message

Andre F

unread,
Jan 2, 2023, 5:57:19 PM1/2/23
to wx-u...@googlegroups.com
Currently I've manually configured wxkeyevent's for one of my simplebook panels and It captures the key events fine.  Is there a way to run or initiate a button click without using the mouse click.  I would like to type the hotkey "a" and have a certain button run.  I've got around this issue by simply running the code from the event handler area(copying the code over).

The problem is there are a bunch of keys and the code is long in some cases.  I was hoping I could just use a one liner that would tell the program to run button23 if xyz, etc... 

Regards,

Kenneth Porter

unread,
Jan 2, 2023, 6:18:42 PM1/2/23
to wx-u...@googlegroups.com
--On Monday, January 02, 2023 4:57 PM -0600 Andre F <af68...@gmail.com>
wrote:
You could lift the code into a common routine that's invoked by both the
button and hotkey handlers.

Create a helper function that takes a button, hotkey, and helper function,
and registers both handlers using lambdas.

You could then call the registration function many times, or you could make
a table of the triplets and loop through them.


Andre F

unread,
Jan 2, 2023, 6:36:29 PM1/2/23
to wx-u...@googlegroups.com
OK, Thank you!  I was considering that type of thing.  I just wanted to make sure there wasn't a simple single line way to invoke or initiate a button click before doing the extra work.  It's not that bad, it's just a lot more work than a single line.

Thanks for your time!  Please close this ticket.

Regards,

On Mon, Jan 2, 2023 at 5:18 PM Kenneth Porter <sh...@sewingwitch.com> wrote:
--On Monday, January 02, 2023 4:57 PM -0600 Andre F <af68...@gmail.com>
wrote:

You could lift the code into a common routine that's invoked by both the
button and hotkey handlers.

Create a helper function that takes a button, hotkey, and helper function,
and registers both handlers using lambdas.

You could then call the registration function many times, or you could make
a table of the triplets and loop through them.


--
Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
---
You received this message because you are subscribed to the Google Groups "wx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wx-users+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wx-users/7B3E35A4793A11FD19EE3B01%40%5B192.168.69.69%5D.
Reply all
Reply to author
Forward
0 new messages