Creating event handler for a whole frame

I'm still working through the editor application. It now saves and opens files through the menu (yay!) However, I also want to add short cut keys (cntl - s for save etc.) Is there any easy way to do this?

My approach so far (which doesn't have any code yet) is to add an event handler to the whole frame. The only reference I've found for this is through the docs which refer to:

"To intercept events, you add a DECLARE_EVENT_TABLE macro to the window class declaration, and put a BEGIN_EVENT_TABLE ... END_EVENT_TABLE block in the implementation file. ..."

However, I can't find any exemplar code to imlement this.

Also I see reference to EVT_MENU and through the documentation EVT_* - where might I find a list of these - or are they user defined? If so, how do you define your own?

Thanks in advance.

adam

Yes, it's simpler than that, see the demo for menus. The last one has
shortcuts.

···

-----Original Message-----
From: Adam [mailto:adam@monkeez.org]
Sent: Monday, May 03, 2004 9:13 AM
To: Wxpython-Users
Subject: [wxPython-users] Creating event handler for a whole frame

I'm still working through the editor application. It now saves and opens
files through the menu (yay!) However, I also want to add short cut keys
(cntl - s for save etc.) Is there any easy way to do this?

My approach so far (which doesn't have any code yet) is to add an event
handler to the whole frame. The only reference I've found for this is
through the docs which refer to:

"To intercept events, you add a DECLARE_EVENT_TABLE macro to the window
class declaration, and put a BEGIN_EVENT_TABLE ... END_EVENT_TABLE block
in the implementation file. ..."

However, I can't find any exemplar code to imlement this.

Also I see reference to EVT_MENU and through the documentation EVT_* -
where might I find a list of these - or are they user defined? If so,
how do you define your own?

Thanks in advance.

adam

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Adam wrote:

I'm still working through the editor application. It now saves and opens
files through the menu (yay!) However, I also want to add short cut keys
(cntl - s for save etc.) Is there any easy way to do this?

Look in the demo for wx.Menu. It would appear to be as simple as adding
the key text to your menu string:

menu5.Append(501, "Interesting thing\tCtrl+A", "Note the shortcut!")

I have no idea what you do for non-English locales.

Roger

Roger Binns wrote:

Adam wrote:

I'm still working through the editor application. It now saves and opens

<snip>

Look in the demo for wx.Menu. It would appear to be as simple as adding
the key text to your menu string:

menu5.Append(501, "Interesting thing\tCtrl+A", "Note the shortcut!")

I have no idea what you do for non-English locales.

Thanks guys.

adam

Hi all (but particularly Robin)

I have just upgraded to 2.5.1.5, and I have come across a difference in
behaviour that breaks my code rather badly.

In a wx.Grid, I could set the column width to zero ( SetColSize(x,0) ) and
the column would appear to be invisible. I have some internal coding to
automatically skip to the next column if the user tabs into the invisible
one.

Now 2.5.1.5 will not allow me to specify a column width of less than 15. Any
attempt to do so results in a column with the default width of 80.

Platforms are W2K and GTK1 (RedHat 9).

Please tell me that this is a bug which can be fixed quickly.

Thanks

Frank Millman

Frank Millman wrote:

Hi all (but particularly Robin)

I have just upgraded to 2.5.1.5, and I have come across a difference in
behaviour that breaks my code rather badly.

In a wx.Grid, I could set the column width to zero ( SetColSize(x,0) ) and
the column would appear to be invisible. I have some internal coding to
automatically skip to the next column if the user tabs into the invisible
one.

Now 2.5.1.5 will not allow me to specify a column width of less than 15. Any
attempt to do so results in a column with the default width of 80.

Platforms are W2K and GTK1 (RedHat 9).

Please tell me that this is a bug which can be fixed quickly.

The following code was added to wxGrid::SetColSize so it ignores attempts to resize smaller than the minimum (default 15). This applies to resizing with the mouse too.

     // This test then fixes sf.net bug #645734
     if ( width < GetColMinimalAcceptableWidth()) { return; }

You can call SetColMinimalAcceptableWidth(0) to set the minimum to zero.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Frank Millman wrote:
>
> Now 2.5.1.5 will not allow me to specify a column width of less than 15.

Any

> attempt to do so results in a column with the default width of 80.
>
> Platforms are W2K and GTK1 (RedHat 9).
>

Robin Dunn wrote:

The following code was added to wxGrid::SetColSize so it ignores
attempts to resize smaller than the minimum (default 15). This applies
to resizing with the mouse too.

     // This test then fixes sf.net bug #645734
     if ( width < GetColMinimalAcceptableWidth()) { return; }

You can call SetColMinimalAcceptableWidth(0) to set the minimum to zero.

Thanks for the info, Robin.

In fact, while I was waiting for your reply, I changed my program so that I
do not create grid columns at all for columns that I want to be invisible.
It wasn't too hard - I use a dictionary to translate between columns in my
tablebase and columns in the grid when responding to GetCellValue and
SetCellValue.

This has solved a problem that I had before - I could not prevent a user
from resizing the invisible column with the mouse, and making it visible! I
looked for a function to disable resizing for a particular column, or the
ability to veto the resize event, but I could not find anything.

I came across one other minor glitch with 2.5.1.5, but I have a solution so
I did not need to post anything. It was not a bug, just a change in
behaviour. For the record, here it is.

Frame A creates frame B, with A as parent. Frame B creates frame C, with
Frame A as parent. I could not give C a parent of B, as C is not dependant
on B, so B might get destroyed, but I did not want C to get destroyed as
well. (A is the controlling frame, B is a menu, C is a function selected
from the menu. The user can return to the menu, move around the menu system,
and select another function without closing the original function).

With 2.4.2.4, under both W2K and GTK, if frame C is destroyed, focus returns
to Frame B. With 2.5.1.5, GTK behaves the same, but with W2K focus returns
to Frame A, so you have to click on Frame B before you can continue.

Once I had identified the problem, the solution was simple. I now give Frame
C a parent of None, and it works fine.

Thanks again, Robin.

Frank