12-14-2011 10:58 PM
Well i'm trying to do a custom emoticon textfield and it's almost impossible, but i think i'm near to to that, but i have a problem. I'm overriding the drawtext method and painting the emoticons but when i do that it paints more than once, it's very weird because i just paint one single time, i don't know if its a graphic buffer problem but i would like to know what's happening.
Solved! Go to Solution.
12-15-2011 12:26 PM
Since the Field's paint (and, within it, your drawText) is called by the framework, you never know when it will be called and how many times.
If you take a look at the Field.invalidate(int, int, int, int), you'll realize that there is a way to schedule a repaint of any part of the Field. I know for sure from my experience that BB framework just loves to paint everything in small "bursts", thus invoking your paint more than once. You can find out what portion of your Field is being redrawn by calling graphics.getClippingRect (Graphics graphics is the first parameter of your drawText - I'm assuming you override drawText of a TextField). You can use this info for optimization, but don't over-optimize - this may create a few nasty surprises...
12-15-2011 07:28 PM - edited 12-15-2011 07:29 PM
Hi thanks for your answer i got it solved, my mistake was to belive that the parameter x in the method drawtext always stay at cero during the method execution, it seems that if you whan to draw you will need to set a constant for drawing
06-22-2012 10:33 AM - edited 06-22-2012 11:51 AM
Sorry for being late with response...
Well is a little tricky painting your own emoticons, but you can always achieve it using a custom font, i have used a trial version of a program that allows you to make customs fonts using a previous made one.
what i did was use some not displayable characters like the #1000 (for example) and add it into the font in a blank space (but with the width that you need for your emoticon).
Well the trick if you are going to allow : ), : ( emoticons input, is to change it by the character that belongs to or .
In the method drawLineText (i think is named in that way), you just have to draw your emoticon image above the font character,you MUST remember using a new variable for the x value in that method due if you don't images will have a random behaviour
06-25-2012 03:24 PM
Sorry man but i couldn't find the source code, the trick is on doing your own font and draw the special chars into the drawline function inside your editfield (you have to overwritte this function)
06-26-2012 12:43 AM
at least tell me the font name you are used and that supports the emoticons and text. i searched in the google but i can't found the exact font.
Can u please share that font or name of the font.
06-26-2012 10:47 AM
No man you are not reading.
A said that you need a custom font, you can take any True Type font, then you have to select any character that is not mapped on it, lets say the character 0x1000 and you have to insert into the font as an empty character with the widh you want.
Then you just have to paint an image over the 0x1000 character in de drawtextline method