Post

Replies

Boosts

Views

Activity

Reply to Passing string between Swift and C++
As you mentioned, we too see 'best' as a 'reliable and safe' approach. Yes, we're mainly concerned with bridging between C strings and Swift Strings. The implicit conversion provided in Approach 2 uses std::string and while we can obtain the C string from this std::string, we're not supposed to use the std data structures - so maybe approach 3 or 1 is the way to go - or something different that is not known to us yet. What would you recommend?
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’25
Reply to How to capture the currently pressed key when a TextField is in focus?
Thanks for the quick responses! @Claude31 's solution covers almost all my use cases except for one. I am unable to detect modifier-only keypresses with the above approach. TextField ("Enter text...", text: $txt) .onKeyPress(action: {keyPress in print ("key: \(keyPress.key), modifier: \(keyPress.modifiers)"); return .ignored; }) For eg, nothing gets printed when I press only the Alt key. I ask this since my application has to allow the user to experience additional functionality on press of special keys - like pressing the Alt key may trigger a particular menu on a particular screen. How can I detect such keypresses, or is it not possible by design? The intent is to be able to implement custom functionality corresponding to an extensive set of hotkey combinations and modifier-only keys. Please correct me if I'm approaching the problem in the wrong direction.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’25