Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to assign escape as key equivalent to a button in swift?

Tags:

swift

I've got working code in objective c class which is like follows :

closeButton.keyEquivalent = @"\e";

This does not work in swift, as it says "Invalid escape sequence in literal." I've tried to use the following code:

closeButton.keyEquivalent = "\u{53}"

But also no luck. Any ideas ?

like image 930
Krzysztof Avatar asked Feb 16 '15 12:02

Krzysztof


1 Answers

You need to assign

closeButton.keyEquivalent = "\u{1b}"

Just tried in a test app.

Edit: According to @Lucasware's comment the ObjC assignment is

[NSString stringWithFormat:@"%C", 0x1b]
like image 155
qwerty_so Avatar answered Nov 01 '22 19:11

qwerty_so