BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 11-06-2009, 05:47 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Mar 2007
Location: India
Model: 8100
Carrier: Airtel
Posts: 64
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default custom text field not consuming input for 8300 and 8520

Please Login to Remove!

Hi All,



I have developed a custom textfield. The code is working fine for 9530 and 8100.. but its not taking input for 8300 and 8520



Here is my code





import net.rim.device.api.ui.component.BasicEditField;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;


import java.util.Vector;

public class CustomTextField extends BasicEditField{
private boolean isSearchBox;
private Font textFieldFont;
private int textFieldHeight;
private int textFieldWidth;
private int scrollIndex;
private int linesOfLabel;
private int startIndex;
private boolean isEndOfText;
private Vector vecData;


public CustomTextField(String txt, int ht){
super("", txt, 30, BasicEditField.EDITABLE | BasicEditField.NO_NEWLINE |
BasicEditField.FIELD_VCENTER | BasicEditField.NO_LEARNING | BasicEditField.FIELD_HCENTER);
isSearchBox = true;
textFieldFont = Data.mainListFont; //font defined in other class
if(ht != 0){
textFieldHeight = ht;
}else{
textFieldHeight = textFieldFont.getHeight();
}
textFieldWidth = Graphics.getScreenWidth()-90;
setText(txt);
}

protected void layout(int width, int height){
super.layout(textFieldWidth, textFieldHeight+5);
setExtent(textFieldWidth, textFieldHeight+5);
}

protected void paint(Graphics graphics){
try{
graphics.setColor(0x620000);
graphics.setFont(textFieldFont);
if(isSearchBox){
graphics.drawRect(0, 0, Graphics.getScreenWidth() - 90, textFieldHeight+2);
}
graphics.setColor(0x620000);
super.paint(graphics);
graphics.setColor(0x620000);
graphics.setFont(textFieldFont);
}catch(Exception ex){
System.out.println("Exception in paint :: CustomTextField "+ex.toString());
}
}

public int getPreferredWidth(){
return textFieldWidth;
}

public int getPreferredHeight(){
return textFieldHeight+5;
}

protected void onUnfocus() {
if(!isSearchBox){
this.setCursorPosition(0);
}else{
this.setCursorPosition(getText().length());
}
invalidate();
}

protected void onFocus(int direction) {
if(!isSearchBox){
this.setCursorPosition(0);
}else{
this.setCursorPosition(getText().length());
}
invalidate();
}

public void setText(String str){
super.setFont(textFieldFont);
super.setText(str);
invalidate();
}

public boolean trackwheelClick(int status, int time){
if(!isSearchBox){
return super.trackwheelClick(status, time);
}else{
return true;
}
}

}



Please can anybody help me..



Thanks
__________________
Crazy for BlackBerry
Offline  




Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.