I have implemented a complicated UITextInput that works quite well on iOS save for one missing feature:
when the user has a hardware keyboard connected (at least, in the simulator) and no text is selected, and presses Forward Delete, nothing happens.
Note that I am NOT referring to the key labeled Delete on a Mac, which is just a Backspace key -- that works correctly already, using an implementation of the UIKeyInput deleteBackward method.
Two questions:
Is it possible for iOS to process Forward Delete correctly (for example a Bluetooth Mac hardware keyboard with Fn + Delete aka not Backspace, but Forward Delete). This works on my Mac laptop? (The answer seems like a yes because I just tested Forward Delete on a hardware keyboard (my host Mac dev machine) in the Simulator in Safari.)
If it is possible and common in other apps, how do I intercept this key command? I cannot find what to send as the string to create a UIKeyCommand, nor can I find any API method that makes sense to do this in an easy fashion.
Note also that selecting text and pressing the Forward Delete key works properly already in this custom text editor, so it appears iOS knows about this key.
FYI this code is in C# but answers to part (2) in Swift or Objective-C would be welcome as well.
(My current best guess might be try messing with the code in this question ? -- Seems like a real headache just to get this one fairly common key?)
UPDATE:
Now pressing Delete (right-delete not backspace) somehow works on iOS, at least the simulator. It may have been a bug in the TextInput system since now when I press the right-Delete key, the system calls my code to select a single character to the right of my cursor and then calls my DeleteBackwards code to delete the selection (which code knows how to delete selected text). Strange but happy this is working as expected now, "out of the box".
You can use Unicode code point 0x7f, for example in Swift:
UIKeyCommand(input: "\u{7f}", modifierFlags: [], action: #selector(forwardDelete))
Objective-C:
[UIKeyCommand keyCommandWithInput:[NSString stringWithFormat:#"%C", 0x7f] modifierFlags:0 action:#selector(forwardDelete)]
Related
As nice as debuggers have gotten these days, sometimes the best way of finding out what is going on in an app is still ye olde NSLog. Doing this is easy when you're tethered to your computer; Xcode helpfully pops up the Log Viewer panel and there you go. Not so easy to do when you're away from your desk, as you sometimes have to be when testing an app (for example, when you are testing CoreLocation functionality). Sure you can pop open Xcode and check the Console section of the Device Organizer as soon as you get back from a testing run, but then you have to wait, and by the time you can get back to view the logs you forgot what was going wrong with your app; also odds are that by the time you are able to do this, the log messages you are looking for have scrolled off into oblivion.
Is there any way of checking the console logs on the device itself? I'm guessing the answer is "no, unless you jailbreak" (IIRC there are at least one or two terminal apps in jailbreak-land that I could use to do this sort of thing). Unfortunately jailbreaking is not an option for me.
Alternatively, is there some sort of Objective-C framework or library or whatnot that handles log collection and on-device displaying? Ideally this would come in the form of a drop-in replacement for NSLog, whereby I could simply do a search-and-replace and change all occurrences of NSLog to SomeFancyPantsLoggingTool or whatever and be done with it.
A good example of the kind of functionality I am looking for can be found in the podcast client Downcast. If you tap the "More" tab, then tap on the version number string at the bottom of the screen, a new view slides up that contains a scrollable view of accumulated log messages. It even has an easy way of mailing said logs to a support e-mail address.
Take a look at LibComponentLogging which you can configure to output logging at different levels and to different destinations.
There is a file for the SysLog. You can simply open it and read from it. The file is at /var/log/syslog. If the file does not exist there are instructions on how to set it up here.
I need my webapp to display a 'keypad' on the screen that makes special-purpose data entry very easy... can't be flash since needs to work with ipad (and also work from regular pc/browser/ mouse).
The simplest variation would be a 'calculator' app where they press number keys and functioin keys and the app takes the input and displays results.
we very specifically need to provide data input from our webapp screen by click/touch 'keys' -- not from the PC keyboard (or soft keyboard on ipad)
I have no idea where to start... any ideas would be appreciated! For example is there some nifty ajax and/or jquery thingy that lets you build an input keypad?
https://github.com/davidnorth/JsReckoner you can take this repo for your base and modify it. Good luck
I have an exceedingly simple USB device. There is no driver provided and instructions are to open an editor and manpulate the device (let's not confuse the issure by dicussing the device) to see the result.
Sure enough, if I open Notepad in Windows and manipulate the device a text string appears in Notepad.
Ok, it looks like it is writing to stdin. Now I would like to write a Delphi program to take this input and act upon it ...
How should I best go about it?
The form doesn't seem to be receiving KeyDown/KeyUp/KeyPress events. That's a pity as it would allow the device to 'interrupt' me. But, maybe I have to poll? Every so often (how often?) I could attempt read from stdin - but what if there is nothing to read?
I hope that I explained that clearly. Any advice?
Update: oops, my bad - I wasn't receiving KeyDown/KeyUp/KeyPress events because I forgot to set the form's KeyPreview to True. But I am awarding the question to Greg because he tried to help and because HID looks interesting. Thanks, Greg.
It sounds like your device is using the HID (Human Interface Device) USB class and is acting like a keyboard. So, you would read from the keyboard exactly as you normally would, manipulate the device in whatever way is appropriate (scan a bar code, whatever) and the keystrokes will come through as if they were typed.
sorry for this little bit strange title, didn't found a better one..
I've got the following situation:
I have a PC with an RFID reader connected via USB.
I now need a program which pops up when ab transponder was scanned the the RFID reader and shows the scanned value. (The reader just simulates keystrokes)
Problem: the value of the transponder is something like 0001230431, and I can't change it. (To prefix a hotkey combination or so)
So I have thought about using a global keyboard hook, check if three zeros where typed in, capture rest of data and when the 10 digits are complete, call the application through an automation object and show the number.
But I'm not very exalted about using a global keyboard hook. Many AV programs don't like them very much, they are not so easy to handle with Delphi and I guess that's not very resource-friendly for such a little task...
So I'm looking for an alternative solution...maybe somebody has an idea?
Big thx!
ben, you can use the RegisterRawInputDevices and GetRawInputData functions.
first you must use the RegisterRawInputDevices function to register the input device to monitor and then you can retrieves the data from the input device using the GetRawInputData function.
Check theses functions too
GetRawInputDeviceList retrieves the list of input devices attached to the system.
GetRawInputDeviceInfo retrieves information on a device.
Why not make sure the Delphi app with a text edit control has focus before the scan is done? Then the keystrokes will go straight into your Delphi app.
I've written some BlackBerry apps, but now i'm trying to write one that must access the hardware (keyboard) in some low level way, and I can't seem to find a way to do it, nor any help to it in the 'official' boards.
The thing is, I need to know when, at any time, the '$' key is pressed in the blackberry keyboard, so my app (or resident service) can catch it, stop the '$' char from displaying, and if the user presses a vowel next, then add an accent to that vowel... and if it presses another key, just send back the '$' char + the other char.
i.e. '$' + 'a' = รก
In other words, I need to create an app or service that converts the '$' key into an accent key, just like typical non-US PC keyboards works.
Now here's the problem: The whole Blackberry OS works under a Java Virtual Machine (Kind of making the JVM the actual OS). So as you can imagine, every app written for it is written in Java.
There's obviously a set of special blackberry api libraries into their Java implementation so the developer is able to access particular Blackberry functions and features... however there doesn't seem to be a thing that I can use to achieve my particular task.
But then maybe there is, and I haven't found it, since I'm still new to Blackberry Programming.
So, in that note, any help or comment will be greatly appreciated.
-Gabriel Alonso.
A screen need to have the focus to be able to get key Event.
RIM dosen't allow low level access to their hardware for security reason.
Press and hold a letter key and roll the thumb-wheel to scroll through international/accent characters, equation symbols and other marks.
Here is the source
Blackberry do not allow execute applications, if they use certain API, not to mention the low-level programming.
All that you can use in your applications for keypad handling - it is possibilities of Java. Like KeyListener interface and Keypad class.
This is a very late reply, however...
You can use keyChar (member of screen, and of KeyListenerInterface) to intercept any key - for the first letter, capture the key pressed. If it's "$" hold onto it and don't call super.keyChar. On the next keyChar (or after a delay with no input) perform your mapping if $ was previously pressed, and send your designed character code to the super.keyChar call. keyDown and keyUp can be used similarly if keyChar presents implementation issues.