@author Eugene Stahov @version
| 40 | * @version |
| 41 | */ |
| 42 | public class MIDPTextBox implements CommandListener { |
| 43 | |
| 44 | private Displayable parentView = midlet.BombusMod.getInstance().getCurrentDisplayable(); |
| 45 | |
| 46 | protected Command cmdCancel=new Command(SR.MS_CANCEL, Command.BACK, 99); |
| 47 | protected Command cmdOK=new Command(SR.MS_OK, Command.OK /*Command.SCREEN*/, 1); |
| 48 | |
| 49 | private TextBox t; |
| 50 | |
| 51 | private TextBoxNotify tbn; |
| 52 | |
| 53 | /** |
| 54 | * constructor |
| 55 | */ |
| 56 | public interface TextBoxNotify { |
| 57 | void OkNotify(String text_return); |
| 58 | } |
| 59 | |
| 60 | public MIDPTextBox(String mainbar, String text, TextBoxNotify tbn, int constraints) { |
| 61 | |
| 62 | t=new TextBox(mainbar, text, 150, constraints); |
| 63 | |
| 64 | this.tbn=tbn; |
| 65 | |
| 66 | t.addCommand(cmdOK); |
| 67 | t.addCommand(cmdCancel); |
| 68 | |
| 69 | t.setCommandListener(this); |
| 70 | midlet.BombusMod.getInstance().setDisplayable(t); |
| 71 | } |
| 72 | |
| 73 | public MIDPTextBox(String mainbar, String text, TextBoxNotify tbn) { |
| 74 | this(mainbar, text, tbn, TextField.ANY); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Called when action should be handled |
| 79 | * @param command |
| 80 | * @param displayable |
| 81 | */ |
| 82 | public void commandAction(Command command, Displayable displayable) { |
| 83 | if (command==cmdCancel) { destroyView(); return;} |
| 84 | if (command==cmdOK) { destroyView(); tbn.OkNotify(t.getString()); return;} |
| 85 | } |
| 86 | |
| 87 | public void destroyView(){ |
| 88 | midlet.BombusMod.getInstance().setDisplayable(parentView); |
| 89 | } |
| 90 | } |
nothing calls this directly
no test coverage detected