04-20-2010 09:56 AM
Hi there everyone, I'm new here and I'm new to blackberry development.
For a student project I'm working on, I have a 2D array of ButtonFields, (which I may change to LabelFields if its easier) which I am using to create a Sudoku grid.
I understand it's really basic but I want to the user to be able to just scroll through the 2D array to a particular cell and be able to type in a number using the keypad to instantly change the label of the ButtonField or LabelField, ie their guess of the Sudoku.
I'm really having trouble as I'm not familiar with how the blackberry accepts user input and how this can be used with the setText method.
So essentially i'd like some sort of way of determining which cell is currently selected (without it being clicked) and then for this currently selected cell to have the setText() method applied to it
Can anybody help me? I can post up code if it helps but I'm not sure it will as you'll al understand how basic it is.
Thank you in advance and I hope I can return the favour soon
Solved! Go to Solution.
04-20-2010 11:10 AM
you can use a focuschangelistener to be aware of focus changes. or call getLeafFieldWithFocus() to retrieve the current field.
you cannot make buttonfields editable, but you can read the user input and process it.
for sudoku you need only the numbers, you can use the keyChar method to read entered characters.
check if your focused field is one of your buttons. check if the entered char or alted char (Keypad.getAltedChar) is a digit (Characters.isDigit).
you can call setText on the buttonfield.