You Are Here:

Community: Developer Discussion Boards

#1 Old Problem with TextField and CustomItem on the same Form - 2006-01-01, 04:16

Join Date: Nov 2004
Posts: 70
manmli
Offline
Regular Contributor
With S60 2nd ed FP 2 emulator, I append a TextField and then a CustomItem to a Form. When input into the TextField "this is brand new to bob", I get "this is brand new to bmb". The text wraps at the letter "o" and triple tap does not work. I can only get a "m". Below are the codes and you can see that it is quite simple. Any one knows what the problem is? (You must use the keys on the emulator to input the text string in order to duplicate the problem)

import java.util.Vector;

import javax.microedition.lcdui.*;

public class StationSign
extends CustomItem
implements Runnable {
private Vector mValues;
private int mSelection;
private boolean mTrucking;

private Display mDisplay;
private Font mFont;
private int mVisibleIndexTimesTen;
private boolean mFocus;

public StationSign(String title, Display display) {
super(title);
mDisplay = display;
mValues = new Vector();
mSelection = 0;
mTrucking = true;
mFont = Font.getFont(Font.FONT_STATIC_TEXT);
mVisibleIndexTimesTen = mSelection * 10;

Thread t = new Thread(this);
t.start();
}

public void add(String value) {
if (value == null) return;
mValues.addElement(value);
}

public void remove(String value) {
if (value == null) return;
mValues.removeElement(value);
}

public String getSelection() {
if (mValues.size() == 0) return "";
return (String)mValues.elementAt(mSelection);
}

public void flip() {
mSelection++;
if (mSelection >= mValues.size()) mSelection = 0;
}

public void dispose() {
mTrucking = false;
}

// Runnable interface.

public void run() {
while (mTrucking) {
int target = mSelection * 10;
if (mVisibleIndexTimesTen != target) {
mVisibleIndexTimesTen++;
if (mVisibleIndexTimesTen >= mValues.size() * 10)
mVisibleIndexTimesTen = 0;
// repaint();
}
try { Thread.sleep(50); }
catch (InterruptedException ie) {}
}
}

// CustomItem abstract methods.

public int getMinContentWidth() {
// Loop through the values. Find the maximum width.
int maxWidth = 0;
for (int i = 0; i < mValues.size(); i++) {
String value = (String)mValues.elementAt(i);
int width = mFont.stringWidth(value);
maxWidth = Math.max(maxWidth, width);
}
// Don't forget about the title, although we don't
// really know what font is used for that.
int width = mFont.stringWidth(getLabel()) + 20;
maxWidth = Math.max(maxWidth, width);
return maxWidth;
}

public int getMinContentHeight() {
return mFont.getHeight();
}

public int getPrefContentWidth(int width) {
return getMinContentWidth();
}

public int getPrefContentHeight(int height) {
return getMinContentHeight();
}

public void paint(Graphics g, int w, int h) {
int fraction = mVisibleIndexTimesTen % 10;
int visibleIndex = (mVisibleIndexTimesTen - fraction) / 10;
String value = (String)mValues.elementAt(visibleIndex);

g.setFont(mFont);
int bc = mDisplay.getColor(Display.COLOR_BACKGROUND);
int fc = mDisplay.getColor(Display.COLOR_FOREGROUND);
if (mFocus == true) {
bc = mDisplay.getColor(Display.COLOR_HIGHLIGHTED_BACKGROUND);
fc = mDisplay.getColor(Display.COLOR_HIGHLIGHTED_FOREGROUND);
}
g.setColor(bc);
g.fillRect(0, 0, w, h);
g.setColor(fc);

// Simple case: visibleIndex is aligned on a single item.
if (fraction == 0) {
g.drawString(value, 0, 0, Graphics.TOP | Graphics.LEFT);
return;
}

// Complicated case: show two items and a line.
int lineHeight = mFont.getHeight();
int divider = lineHeight - lineHeight * fraction / 10;

// Draw the piece of the visible value.
g.drawString(value, 0, divider - lineHeight,
Graphics.TOP | Graphics.LEFT);
// Now get the next value.
visibleIndex = (visibleIndex + 1) % mValues.size();
value = (String)mValues.elementAt(visibleIndex);

// Draw the line.
g.setStrokeStyle(Graphics.DOTTED);
g.drawLine(0, divider, w, divider);

g.drawString(value, 0, divider,
Graphics.TOP | Graphics.LEFT);
}

// CustomItem methods.

protected void keyPressed(int keyCode)
{
flip ();
}

protected void pointerPressed(int x, int y)
{
flip();
}

protected boolean traverse(int dir,
int viewportWidth, int viewportHeight,
int[] visRect_inout) {
mFocus = true;
repaint();
return false;
}

protected void traverseOut() {
mFocus = false;
repaint();
}
}
_____________________

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class StationSignMIDlet
extends MIDlet
implements CommandListener {
public void startApp() {
Display display = Display.getDisplay(this);

//System.out.println(System.getProperty("microedition.encoding"));
Form form = new Form("StationSignMIDlet");

TextField text = new TextField("input text", "initial text", 100, TextField.ANY | TextField.NON_PREDICTIVE);
form.append(text);

StationSign ss = new StationSign("Destination", display);
ss.add("Albuquerque");
ss.add("Savannah");
ss.add("Pocatello");
ss.add("Des Moines");
form.append(ss);

Command c = new Command("Exit", Command.EXIT, 0);
form.addCommand(c);
form.setCommandListener(this);

display.setCurrent(form);
}

public void pauseApp() {}

public void destroyApp(boolean unconditional) {}

public void commandAction(Command c, Displayable s) {
if (c.getCommandType() == Command.EXIT)
notifyDestroyed();
}
}
Reply With Quote

#2 Old Re: Problem with TextField and CustomItem on the same Form - 2006-09-01, 15:14

Join Date: May 2006
Posts: 3
corywinter
Offline
Registered User
We have also run into this problem and it's not limited to the emulator. It seems that 2nd and 3rd Generation Series 60 devices are afflicted. We have tried and duplicated the issue on 3230, 6260, 6600, 6680, E70, N73 and more! Removing the custom items from the form allows the TextField to work as expected but this is not a viable workaround. Can someone at Nokia comment on this issue?
Reply With Quote

#3 Old Re: Problem with TextField and CustomItem on the same Form - 2006-09-01, 20:09

Join Date: Apr 2003
Posts: 6,408
Location: USA, CA
hartti's Avatar
hartti
Offline
Nokia Expert
I'll check this (hopefully today)

Hartti
Reply With Quote

#4 Old Re: Problem with TextField and CustomItem on the same Form - 2006-10-13, 07:27

Join Date: Dec 2004
Posts: 3
shadmi_d
Offline
Registered User
Any updates about this problem?
Reply With Quote

#5 Old Re: Problem with TextField and CustomItem on the same Form - 2007-10-18, 12:43

Join Date: Oct 2007
Posts: 1
raquibulbari
Offline
Registered User
Please let me know update of this thread, i am facing similar problem.
I am facing another problem, by adding two custom items is the same form,
then for some reason traverse is getting out of control though i am returning true to stay in the item
Reply With Quote

#6 Old Angry Re: Problem with TextField and CustomItem on the same Form - 2008-04-22, 22:29

Join Date: May 2007
Posts: 22
Peanuts1971
Offline
Registered User
Oh no, now I get a sick feeling.

This problem was first logged in 2006, it is now 2008 and my users informed me they are too seeing this on my application.

A textbox (textfield) with a customitem on a form, just doesnt tripple tap right.

Did anybody come up with a solution?

Does it mean I have to write a customitem to replace the textbox?

AAARGGH!!!
Reply With Quote

#7 Old Re: Problem with TextField and CustomItem on the same Form - 2008-04-24, 11:44

Join Date: Apr 2003
Posts: 6,408
Location: USA, CA
hartti's Avatar
hartti
Offline
Nokia Expert
Oh, boy, have I dropped the ball on this. Sorry for that. Too many things to do.

Anyway, I have replicated this problem. So far I did not find any workarounds (other than removing the CustomItem).

My to do
a) write known issue doc for this
b) check from dev team to get this fixed, although the current devices will not likely see any fixes for this.

Hartti
Reply With Quote

#8 Old Re: Problem with TextField and CustomItem on the same Form - 2008-04-24, 22:45

Join Date: May 2007
Posts: 22
Peanuts1971
Offline
Registered User
Hello Hartti,
Not to worry! I found a work-around for my limited use of customitem. This is what you do:
Take the customitem off the form. Do NOT have the custom item on the form. However, I kept everything of the customitem, specially the paint. The paint basically draws an image onto memory. As you may recall from the double buffering method, the trick is to write the image you create in paint to your own image item. From then on its as simple as falling out of the tree. Put a IMAGEITEM on the form, and just populate it with the image you have saved from your paint. Im nearly done doing it, so far so good, gonna work like a charm. (Remember to initialise - create- your customitem somewhere, such as in startapp.)
I hope I explained it well enough.
That is a quick workaround, of course it doesn't give you traversing inside the image on the form, since it is only an image, but why worry, if you only want to display the image to the user and there is no associate logic/controls/events with it?
Take care and, ya, bugfixes hehe, nasty.
Reply With Quote

#9 Old Re: Problem with TextField and CustomItem on the same Form - 2008-12-23, 14:10

Join Date: May 2008
Posts: 13
schoudri
Offline
Registered User
I am too facing the same issue. Any updates on this issue. Any workarounds available?
I can't use an image as the custom item contents need to be scrollable.
Thanks
Sandeep
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
CustomItem size zohar Mobile Java General 0 2005-12-04 13:27
CustomItem size zohar Mobile Java Media (Graphics & Sounds) 0 2005-12-04 10:41
TextField too eager to get out of the way Zigurd Mobile Java General 2 2005-08-24 21:06

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia