Escape key not firing on child window

I have a problem with a window’s keydown event not intercepting the Escape Key. I use it here to close the window. I thought it was because it was a modal window, so I eliminated that. The code works fine on a PC.

I’m not sure what else could be causing this. I don’t have any other keydown event.
The focus is on a texture, but the key works on a PC so, I don’t know what is happening.

Suggestions

I added to the TextArea a KeyDown event to make sure the Escape key was being honored. The TextArea did read the Escape key but the return didn’t go anywhere. It ended there.

Yes I did restart my Mac and even did Option-R-Command-P just in case

Sure you have Return true in the keydown event?

1 Like

Yes. And in just in case the world is crazy, I tried Return False. It didn’t get to the window’s KeyDown.

Edit. Oops. misread my code for my previous edit

How are you detecting the escape key?

I seem to recall that escape on the Mac is ASCII 27

This is the first line in that window’s keyDown event.
If (Key = String.ChrByte(13) Or Key = String.ChrByte(03) Or key = String.ChrByte(27)) And Changed = False Then//Chrb(27) = escape

This line’s purpose is to close the window

I removed the other Keydown event, since I knew it wasn’t getting here.

At one point I had this as an explicit window. I also had it as Modal, but decided against it in order to have a menu. Menues if I remember right don’t go with Modal windows.

This works for me, providing a text field doesn’t have the focus.

select case ASC( key )
case kASCEscape // --- This is a constant defined in OAK2020
  self.close
  
end select

Edit: Alternatively, drag a cancel button out on to the window, and position it out of frame. This works, even if the text field has focus.

Grumble. I’m sure the text area has the focus. I tried the cancel button with its own Keydown and it didn’t work. I think I’ll put the event in the text area and just close it from there.

Thanks also for the idea of a button off of screen. I had always disabled them, but now I might make them work.

1 Like