| Reply | « Previous Thread | Next Thread » |
|
Hi,
Can anyone could tell me how can I know wicth texfield is selected or have the focus? My goal is that I have two TextField's and for each one I have two different screens with ChoiceGroup to fill after do the correct choice. I have a command that go to the correct screen. What I want is when the focus is in TextField1 and when I press command it go's to Screen1. When the focus is in TextField2 and same command is pressed it go's to Screen2. Can ayone help me on this? Thanks, decisor |
|
Hi,
U can do this way. Add the same command,say Okcommand both the items (Textfield1 & Textfield2) rather than to the form as a whole. Then set the itemcommandlistener to the two items. U can get the commandAction(Command c, Item item) based on the item of which the focus is now enabled. Hope this is helpful. This is the one which comes to my mind first. someone else will post a more easier or staright way to do this. Wang |
|
Thanks wang_shui.
I will try and then let you know. decisor |
|
Join Date: Dec 2005
Posts: 1,696
Location: Europe/Poland/Warsaw
Offline
Super Contributor
|
|
hi decisor,
use setDefaultCommand to have better control (and less commands), try sample: import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class TwoTextTest extends MIDlet implements CommandListener, ItemCommandListener { public void startApp() { txtFirstItem.setDefaultCommand(editCommand); txtFirstItem.setItemCommandListener(this); txtSecondItem.setDefaultCommand(editCommand); txtSecondItem.setItemCommandListener(this); mainForm.append(txtFirstItem); mainForm.append(txtSecondItem); mainForm.addCommand(exitCommand); mainForm.setCommandListener(this); Display.getDisplay(this).setCurrent(mainForm); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void commandAction(Command command, Item item) { if(item == txtFirstItem){ Alert alert = new Alert("Info:", "First text field selected!", null, AlertType.INFO); Display.getDisplay(this).setCurrent(alert); }else if(item == txtSecondItem){ Alert alert = new Alert("Info:", "Second text field selected!", null, AlertType.INFO); Display.getDisplay(this).setCurrent(alert); } } public void commandAction(Command command, Displayable displayable) { if(command == exitCommand){ Display.getDisplay(this).setCurrent(null); destroyApp(true); notifyDestroyed(); } } // private Form mainForm = new Form("Example"); private TextField txtFirstItem = new TextField("first item", "FIRST", 20, TextField.ANY); private TextField txtSecondItem = new TextField("second item", "SECOND", 20, TextField.ANY); private static final Command editCommand = new Command("Check", Command.ITEM, 1); private static final Command exitCommand = new Command("Exit", Command.EXIT, 1); } hth, regards, Peter |
| peterblazejewicz |
| View Public Profile |
| Find all posts by peterblazejewicz |
|
Hi peterblazejewicz,
Thank's a lot.... Works perfectly, for my needs :) :) :)!!! Just kiding. Hope that helps another users too. decisor |
|
Join Date: Dec 2005
Posts: 1,696
Location: Europe/Poland/Warsaw
Offline
Super Contributor
|
|
Hi decisor,
glad that worked, I'm on my learning curve edge :D cheers, Peter |
| peterblazejewicz |
| View Public Profile |
| Find all posts by peterblazejewicz |
|
Hi again peterblazejewicz,
Can I do some like this using MIDP-1.0??? What the chances to do something similar?!??!?!?!?!?!?! Thanks, decisor EDIT -------- 2006-07-10 17:53 ------------- I've already got the "solution". The question is that for running for example in Nokia 6600 I put CLDC-1.0 and MIDP-1.0 wicth is no need. The only thing needed it's putting CLDC-1.1 and MIDP-2.0. Sorry guys. Hope this help anyone. decisor
Last edited by decisor : 2006-07-10 at 18:58.
|
|
Join Date: Dec 2005
Posts: 1,696
Location: Europe/Poland/Warsaw
Offline
Super Contributor
|
|
hi,
so to just answer it should be probably possible with setItemStateListener(listener) method from MIIPD 1.0, not tested with real device but with S60 3rd edition emulator and WTK 2.2 emulator, class declaration changed: PHP Code:
PHP Code:
PHP Code:
hth, regards, Peter |
| peterblazejewicz |
| View Public Profile |
| Find all posts by peterblazejewicz |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| TEXTFIELD NAME 问题 | tahwee | Other Programming Discussion 关于其他编程技术的讨论 | 0 | 2006-04-10 08:24 |
| newB - TextField issue | tetsujin1979 | Mobile Java General | 2 | 2005-08-16 10:29 |
| Cannot use textField after delete and insert in Form | andretr | Mobile Java Tools & SDKs | 1 | 2004-08-03 14:33 |
| TextField refresh problem with Nokia devices | RalfHupfer | Mobile Java General | 1 | 2004-07-02 02:35 |
| Simple TextField question. Thaks | matteopiccioni | Mobile Java General | 1 | 2003-12-03 12:32 |