Crash if return key is pressed, but keydown does not trigger.

I have an desktop program that allows the user to select a PostScript file via GetOpenFolderItem. The program then performs various operations on the input file and produces an output file, calling GhostScript and PDFTK via shell along the way. There are a few fields in the GUI where the user may optionally enter values (for instance, horizontal and vertical shift) and a few checkboxes (rotate), and also some buttons (do a best guess on shift).
Program seems to work fine if I operate it exactly as I intended.
But, in testing I discover that if the return key is pressed it almost always causes a crash. The crash happens on key down, not key up. It happens if I have no field selected, or a field that allows user input has focus.
Example: LRShift allows the user to enter the distance to shift the image, with negative values moving left. The If I click on the field and enter -8.5 then tab I move to the next field, and the value is accepted. If I enter -8.5 and then click in a different field, same thing except I move to the field I clicked in, or the button I clicked on is activated, or whatever… all as expected. But if I enter -8.5 and press return, an instant crash. But it’s not that particular field. I can click on a button and get proper action, then press return and get the crash. Essentially, I get a crash no matter where I am if I press the return key, EXCEPT if I am in a listbox. Then, nothing happens (cell editing is not enabled).
I set up a KeyDown event handler for the window and it does not fire. (breakpoint at beginning is not reached.)

Any suggestion? I suspect this is going to be something really simple that I am overlooking.

Do you have a button marked as Default? Return will “press” it if you do.

I do not… At least, I did not intend it to be so. Where does one mark a button as default?
This could be a cure for my issue, though. The buttons would not cause a crash if pressed at the wrong time. If I can make return press an innocuous button, all would be fine.
I am wondering why the keydown does not catch the press, though.

Nevermind on the how to make default. I found it in documentation once you called my attention to the possibility. I will test this as a solution, but would still like to know what’s happening without it.

My buttons were all BevelButtons, which can’t be default, apparently… except for one button, which was Quit. HA! Even though it was not set as default, could that be it? I created a single button, DoNothing, and made it default. All it did was contain a single debug statement. Validate that it’s default because it has a pulsing blue highlight on it.

Pressing “return” key still causes a crash without ever going to that button. So, it’s not the cause, nor is it the solution.

Is there code in your window’s KeyDown event?

[quote=89913:@Gary Carroll]
Pressing “return” key still causes a crash without ever going to that button. So, it’s not the cause, nor is it the solution.[/quote]

When you say “crash” as in “On OS X the Apple Crash reporter dialog shows up ?”
Or the same on Windows ?

Or something else ?

Good question, on the crash. The crash report does NOT show up. It’s as if I pressed the Quit button… the program abruptly ends. Therefore, maybe it is triggering the quit, except I put a breakpoint in the code for that button and it never triggers.

Here is the code for the keydown event handler for the window:
dim debug as string
Select Case Asc(Key)
Case 8 ’ backspace
debug=debug 'just so I can see the “step” execute.
Case 9 ’ tab
debug=debug 'just so I can see the “step” execute.
Case 13 ’ return, on a mac
debug=debug 'just so I can see the “step” execute.
'this one is one I should see.
Case 31 ’ up arrow
debug=debug 'just so I can see the “step” execute.
Case 29 ’ Right arrow
debug=debug 'just so I can see the “step” execute.
Case 30 ’ Down arrow
debug=debug 'just so I can see the “step” execute.
Case 28 ’ Left arrow
debug=debug 'just so I can see the “step” execute.
case 83 ’ S
debug=debug 'just so I can see the “step” execute.
Case else
return false
End Select

OS X/ Windows/ Linux ?

An outright crash should give you the crash reporter or a dialog when you restart the app
I’m suspicious that its “something else”
Do a search for EVERY instance of the QUIT keyword and put a break point on every one
The run your app in the debugger

If a textfield has focus, it will get the KeyDown and the window won’t (at least on Windows). Have you inadvertently assigned Return as the shortcut of a menuitem?

You could also try adding an App.Close event.
If something is QUITting your app, App.Close will be called. If it’s actually crashing, it won’t.