I want to record a user-entered time, but I don't want the user to have to worry about entering things such as ":" or ".". The only times entered will be around 7-8 minutes, and any number of seconds with a possible decimal point, but I would like the user to just be able to enter something like 7234 and have it format to 7:23.4.
Any ideas or hints would be great!
You can do this with a clever use of
– textField:shouldChangeCharactersInRange:replacementString:
(see the documentation for the UITextFieldDelegate Protocol).
If you know for certain that the time will always be <10 minutes, then after the first numeric entry, add : and after the next two add .. However, it may be easier to use different fields for minutes and seconds. For instance, what if the user enters 713... how would you parse this? 7:13 or 7:1.3?
I am going to recommend an alternate approach. Since you can't predict where the : and . should go if the user enters a continuous piece of text. You should rather present a picker view when the user taps on the text field and let the user pick the time. This works by setting a UIPickerView object as the inputView of the UITextField. Ideally an easier tool would have been a UIDatePicker but it doesn't have seconds in any of its modes. So you will have to create a picker view with 3 components - minutes, seconds and milliseconds. You will have to become its data source and the delegate and provide all the possible values for the three components. You will also need to add a view (a UIToolbar perhaps) with a button that resignsFirstResponder for the text field.
Personally I am biased towards this approach but it is only available since iOS 3.2 which should be a part of your consideration.
If it is not absolutely necessary to use only one textfield, you could perhaps use more?
From left to right, the first one represents the minutes, the second one has 2 places and represents seconds and the third (and last) one represents numbers beyond the decimal point. Then simply switch between them as the user enters the numbers.
You might also want to check out how it's cleverly done for money (which has similar problems to time 100 could be 1.00, or 10.0 or 100) in a Slovenian app called Toshl - when adding expenses.
Related
I was wondering if its possible to customize the behavior of IntelliSense in VS 2012. I also have Resharper installed if that can do it. My desire is to minimize the amount of movement of my hands from the core keys. Typically when IntelliSense comes up I start typing and it narrows the list down to say 3-4 items. Then I need to move my right hand to the Down Arrow Key. I was wondering if I could use the Space key to cycle through the short list of 3-4 items and then hit Enter or ; to select the value I wanted. I can always keep typing the item I want but sometimes that will take 6+ keystrokes since the names are similar. Anyway just wondering as I would think that would be an improvement in speed.
I have a Windows Application in VB.NET. I want to know if a value is entered by a user via the keyboard, or if it is coming from a barcode reader. I want to store values that come from
the keyboard in a different database than the ones the come from the barcode reader.
Option 1:
Get a barcode-scanner that is connected to a serial-port (raw serial device read by a COM port). As most barcode-scanners emulate keyboard strokes there is no way to directly distinguish a barcode scanner input from a keyboard input (see next option) without going low-level (see last update).
One connected to a serial port (or emulated one via USB as serial-ports are not so common anymore) gives you full control on where the input comes from.
Option 2:
Count number of chars typed by time. Barcode-scanners inject a sequence (line) pretty fast compared to typing. Measuring the time used in the textbox by counting key-presses (use CR+LF as a measure point as these are sent by the scanner as well) can give you one method to distinguish if a human is typing (unless there is one typing fast as f) or the content was injected. If timed-out just reject/clear the input.
In addition the checksum of the barcode (if you use one that contains that) can be used to do an extra validation in addition to time measurement.
(you can detect pasting by overriding the ctrl + v as in the next option).
Option 3:
Combine option 2 but instead of measure in the textbox tap into the ProcessCmdKey() function (by overriding it) and measure there if textbox has focus. This way you can first buffer input, measure time and if within a set time-out value, inject the line into the textbox.
Option 4:
This might be a good option as well:
http://nicholas.piasecki.name/blog/2009/02/distinguishing-barcode-scanners-from-the-keyboard-in-winforms/
Option 5: a non-technical approach -
Usability improvements: make it visually very clear that bar-codes must be entered with a scanner and not typed. I am including as an option as it is simple and if made correct also effective (there's no right answer of what is correct unfortunately).
Approached could include f.ex. a watermark in the textbox ("Don't type, scan!" or something in that order). Give it a different color, border, size etc. to distinguish it from normal textboxes, and have a help text associated and available at all time that improves clarity.
This is a part of the iTunes smart playlist creation window; for my application I need to create something very similar to this:
The changes I'll be making would be the column that says artist would be integers (but still a pop up button), same with the second column. The third column would be text input like in the picture. I would like to keep the functionality of the "+" and "-" buttons but I don't have much use for the "..." button. Is there any easy way to recreate this? I need the user to be able to add as many or few fields as necessary.
Thanks in advance!
If you don't need to support 10.4, take a look at NSPredicateEditor. It should allow you to easily recreate iTunes' interface with the changes you describe. http://nvie.com/posts/nspredicateeditor-tutorial/ may be useful to help you get started.
Okay, I've seen the webpage that shows you how to enter a decimal key on the number pad, but that's pretty complicated for one button, and the problem I have involves multiple buttons. See, I have a program that involves typing in functions like "x + 5". My problem right now is that the user has to go through three different keyboards just to enter that kind of function. I need to know if it's possible to set up a keyboard that will have specific keys in it. Is there a way to do this that's simpler than the decimal key method?
You'll have to create a custom keyboard if none of the apple keyboards toots your flute.
The easiest way to do this is to create a view and add lots of buttons with their own titles and background images and, most importantly, actions. You'll also need a delegate.
To be more official, there are numerous online tutorials (and lots of SO questions).
Objecive-C/Cocoa newbie...I have an NSMatrix composed of NSTextViewCells. I would like the user to be able to type at most one letter into each cell, have the letter upcased if necessary, and automatically tab to the next field.
It looks to me as if I can use an NSFormatter to do the upcasing, but I can't figure out how to get the auto-tabbing.
Is it just me, or is the available documentation in general less than wonderful? I've been reading Hillegass' book, which is great, but it only goes as far as it goes :)
Thanks.