- Hi.
I am new to BB development(have been working on it for 3-4 days) and i am stuck with a problem. Here are the details of my IDE.
I am using JDE 4.2.1 and running bb 8800 simulator.
My Project:
I need to display bitmaps on a text field, be it basicedit, edit, richtext.
I am extending EditField:
Code:public class CustomTextField extends EditField implements KeyListener {
Code:protected void paint(Graphics g) { . . super.paint(g); . . g.drawBitmap(x, y, bitMap.getWidth(), bitMap.getHeight(),bitMap, 0, 0); . . }
I am creating a VerticalFieldManager and adding an instance of my CustomTextField:
Code:manager = new VerticalFieldManager(Manager.VERTICAL_SCROLL|Manager.VERTICAL_SCROLLBAR); CustomTextField c2= new CustomTextField("T2:", "", 100,EditField.FOCUSABLE|EditField.FILTER_DEFAULT|EditField.FIELD_LEFT,30); manager.add(c2);
Code:protected void layout(int width, int height) { setExtent(100,100); }
Any advice/suggestions/hints as to how to view past the visible area will be greatly appreciated.
Also, the edit fields default behavior is that when the inserted/typed text reaches the end of the line a new line gets inserted, pushing other fields below it down 1 line. I havent been able to provide this feature with my custom field. I would like to know how to do this.
I hope someone can help me out here.
Thanks in advance!
Regards,
hellcry.11-13-09 04:18 AMLike 0 - QuiteSimpleQuiteSimpleHi,
first at all, why don't you use BitmapField? It seems to do what you are trying to achieve with the CustomTextField
As for the visible area, if you define your VerticalFieldManager with USE_ALL_HEIGHT style, it may help.11-13-09 06:33 AMLike 0 - Thanks for replying back!
Well i think i should provide a few more details about my project.
I am creating a transliterator for BB. It functions similar to Google transliterator. The user enters text in english, presses space and the english word is replaced by the appropriate transliterated bitmap image. So i need textfield to accept user input and then i need to display the bitmap. The reason i am displaying the converted word in bitmap is since BB doesnt provide support for regional(Indic in my case) languages.
I am done coding the transliteration part but now the only hurdle remaining is displaying the obtained bitmap.11-13-09 07:00 AMLike 0 - QuiteSimpleQuiteSimpleI guess that you are not writing every single char, but whole sentence or a bunch of words together. I think that you have to do the line adding by yourself. So you have to compute the line length (Display.getWidth()) or similar method and when you need to add additional line, you could just start drawing at (y+fontHeight) position.
Further is maybe a good idea to define the CustomTextField with USE_ALL_HEIGHT so it takes the whole screen11-13-09 09:06 AMLike 0 - yep. I am drawing one word at a time. And i dont want to use the complete screen. Well, the app i am writing is generic in nature. It will be used to provide applications in regional languages and hence there will be all sorts of fields on the same screen. Imagine a messaging application but only in a regional language. So using the whole screen just for one field beats the bigger purpose.
And i have tried what you have suggested, ie drawing at y+fontHeight after exhausting a line but the problem with that is:
1. If i add the Custom field on to the main/full screen, i am able to write multiple lines but if i have other fields (this might be a difficult to explain..I would have posted some pics if i were in my company but i am not at the moment...)say taking 20pixels height on the screen, then the bitmaps wont be displayed on these 20pixels but when enough number of lines(of bitmaps) are added to out grow the 2nd field, i'll be again able to see the bitmaps. The solution to this will be if i am able to push the 2nd field down one line every time a add a new line to the Custom field. I am not able to find how to do this though.(But the EditField and others do this by default. I wish i knew how!)
2. If i add the Custom field on to the VerticalFieldManager, i have to use setExtent(height,width) to set the bounds of my Custom field(otherwise only one line will be provided by default). I am able to display my bitmaps within this bound, ie only the visible part. To display the hidden part i need to provide a scroll facility and i have no idea ** to do that either.
I wish i had some more experience with BB coding but unfortunately i dont and i have never used Swing or Awt.11-13-09 11:48 AMLike 0 - QuiteSimpleQuiteSimpleThinking of option 1 - if you put all fields inside the same container (no matter if Screen or VerticalFieldManager) and place all of them in the sublayout() method, then you can set their position dynamically based on the same "y" parameter. So every time you need to add line to your CustomTextField you will change the "y" for all, forcing repaint after that should "push" all fields down.11-13-09 03:58 PMLike 0
- Thinking of option 1 - if you put all fields inside the same container (no matter if Screen or VerticalFieldManager) and place all of them in the sublayout() method, then you can set their position dynamically based on the same "y" parameter. So every time you need to add line to your CustomTextField you will change the "y" for all, forcing repaint after that should "push" all fields down.
This is what i know about sublayout(): It is basically used to position the different fields that are added on to the vertical/horizontal field manager. But i do not know how to invoke/use it dynamically. Could you please provide me with a sample code?11-15-09 10:29 AMLike 0 - Code:
Screen/Manager | ------------------------------- | | | CustomTextField OtherFields ...
You want me to add my custom fields and other fields to a Screen(or its scbclasses) or Manager(or its subclasses) and then depending upon the y value in CustomTextField i need to invoke the subLayout method and use setPositionChild to change the location of other fields dynamically.
But the problem is: How do i communicate the y value from CustomTextField to the Screen/Manager and cause subLayout to get invoked?11-17-09 12:40 AMLike 0 - QuiteSimpleQuiteSimpleI'm sorry for not responding lately, too much work to do I will try to create for you a small example, so you can see the idea in action.11-17-09 01:33 AMLike 0
- Forum
- BlackBerry Developers
- Developers Lounge
Issue with Custom Text Field
LINK TO POST COPIED TO CLIPBOARD