Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
urodba
Posts: 12
Registered: ‎08-16-2011
My Device: 9300
My Carrier: Telcel
Accepted Solution

Emoticon issue

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.

Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Emoticon issue

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...

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Contributor
urodba
Posts: 12
Registered: ‎08-16-2011
My Device: 9300
My Carrier: Telcel

Re: Emoticon issue

[ Edited ]

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 

Please use plain text.
New Developer
saran_karma
Posts: 8
Registered: ‎12-28-2011
My Device: BlackBerry® Bold™ 9900
My Carrier: Etisalat

Re: Emoticon issue

 

Hello urodba,

 

I am new developer and looking for same code for the discussed functionality [TextField with Emoticon] .can you please share your code.

 

Thanks in Advance.

Please use plain text.
Super Contributor
bh1r1th
Posts: 273
Registered: ‎11-23-2010
My Device: 9800 torch
My Carrier: Software Programmer

Re: Emoticon issue

Hi There,

i also working on the same thing but i didn't get that.

How can u  get that functionality can u please explain the algorithm once i will implement it in my app.

 

 

Regards,

bh1r1th

Please use plain text.
Contributor
urodba
Posts: 12
Registered: ‎08-16-2011
My Device: 9300
My Carrier: Telcel

Re: Emoticon issue

[ Edited ]

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 :smileyhappy: or :smileysad:.
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

Please use plain text.
New Developer
saran_karma
Posts: 8
Registered: ‎12-28-2011
My Device: BlackBerry® Bold™ 9900
My Carrier: Etisalat

Re: Emoticon issue

[ Edited ]

Thanks for the reply urodba.  

 

Is it possible to share your sample code related to this.

 


Please use plain text.
Contributor
urodba
Posts: 12
Registered: ‎08-16-2011
My Device: 9300
My Carrier: Telcel

Re: Emoticon issue

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)

Please use plain text.
Super Contributor
bh1r1th
Posts: 273
Registered: ‎11-23-2010
My Device: 9800 torch
My Carrier: Software Programmer

Re: Emoticon issue

Hi There,

 

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.

Please use plain text.
Contributor
urodba
Posts: 12
Registered: ‎08-16-2011
My Device: 9300
My Carrier: Telcel

Re: Emoticon issue

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 

Please use plain text.