黑莓 - 面带笑容的文本字段 [英] Blackberry - Smileys in text field

查看:132
本文介绍了黑莓 - 面带笑容的文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方式来插入表情符号/笑脸/任何位图在文本字段中(的LabelField,EditField中,等等)。从我目前为止的研究,有做这个没有直接的办法,所以我坚持,试图模仿这种行为。

I'm looking for a way to insert emoticons/smileys/any bitmap in a text field (LabelField, EditField, whatever). From what I've researched so far, there is no direct way to do this, so I'm stuck with trying to simulate this behavior.

我想用一个普通的文本字段和代替表情插入空格,然后把一些BitmapFields在文本字段中的表情应该是。问题是,我有发现在屏幕上(X,Y)字符的位置没有可靠/快捷方式。

I was thinking of using a normal text field and instead of smileys to insert blank spaces and then place some BitmapFields over the text field where the smileys should be. The problem is that I have no reliable/quick way of finding a character's position on screen (x,y).

你能给我一些想法?

你能想出其他办法解决这个问题?

Can you think of other approaches to this problem?

我敢肯定有很多人遇到这样的问题,在同一时间或其他。我希望是谁的人设法找到解决办法。我绝望到接受任何解决方案,无论多么疯狂/复合/困难。

I'm sure a lot of people encountered this kind of problem at one time or another. I hope there is someone who managed to find a solution. I'm desperate enough to accept any solution, no matter how crazy/complex/difficult.

另外,我想在SDK 5.0使用这个和,但我会满足于仅仅6.0。

Also, I would like to use this in SDK 5.0 and up, but I will settle for only 6.0.

推荐答案

你也许能够做的就是创建一个自定义管理器是EditFields和BitmapFields的容器。当用户点击初始EditField中那是你的经理的内部,开始输入,你让他们输入到他们想要的表情。当他们选择它你EditField中之后创建一个BitmapField,然后将一个新的EditField中的BitmapField的权利。你必须跟踪之类的东西,当用户点击退格键和清空的EditField中,它应该被删除,然后他们选择BitmapField,以及随后的退格键将删除BitmapField,并把重点放在previous EditField中。

What you might be able to do is create a custom Manager that is a container for EditFields and BitmapFields. When the user clicks in the initial EditField that is inside of your Manager and begins typing, you let them type until they want an emoticon. When they select it you create a BitmapField right after the EditField and then place a new EditField to the right of the BitmapField. You'll have to keep track of things like when the user hits backspace and empties an EditField, it should be removed, and then they are selecting the BitmapField, and a subsequent backspace would delete the BitmapField and put focus on the previous EditField.

您也必须创建自己的EditField中,你可以控制的大小和BitmapField,允许退格键将其删除。

You will have to also create your own EditField that you can control the size of, and BitmapField that allows for backspace to delete it.

至于我能想到未来,你不应该使用这个5.0有什么问题。

As far as I can think ahead, you shouldn't have any problem using this for 5.0

修改意见:

您将必须实现自己的经理sublayout()在你采取任何方法,让你知道的位置,因为你是谁把它们放在那里的人。如果要想做多行(我的做法是单行),你可以做三件事情之一:

You'll have to be implementing your own sublayout() of your Manager in any approach you take, so you know positions because you're the one who put them there. If you want to want to do multi-line (my approach was for single-line), you can do one of three things:

1。)只要有每行新EditFields并做链接的方式我讲到哪里退格键将你带到previous现场,在这种情况下的最后一行相同。你必须保持的场有多大基于该文本的测量结果,看看是否将其移动到下一行。如果它只是调整,其中EditFields定位。

1.) Just have new EditFields for each line and do the linking the same way I talked about where backspace drops you to the previous Field, in this case the last line. You have to keep measurements of how big the field is based off of the text, and see if that will move it to the next line. If it does just adjust where the EditFields are positioned.

2。)您可以通过实现自己的EditField中一个可扩展的高度,在这种情况下,你会知道在哪里文字,你是什么线做多行字段中输入您的图像位置。绘制位图是计算(你是什么行数)*(字体高度)和getAdvance(text_up_to_bitmap)的问题。

2.) You can do your image placement in the multi-line field by implementing your own EditField that expands height, in which case you'll know where the text is and what lines you are on. Drawing the Bitmap would be a matter of calculating (what line number you are) * (font height) and getAdvance(text_up_to_bitmap).

3)实现自己的EditField中,你有一个聚焦的经理,你手工做所有的绘图。您可以分析你捕捉击键保存,也许有一个标志,在表情应该是一个字符串。绘制文本之前,画出表情,然后继续绘制文本。与此困难是你必须做的事情一样确定在何处光标是应该的,造就了虚拟键盘,以及处理一些该做EditField中为您的其他任务。

3.) Implement your own EditField where you have a focusable Manager that you manually do all of the drawing. You can parse a String that you save from capturing key strokes and maybe have a flag where an emoticon should be. Draw the text before it, draw the emoticon, then continue drawing the text. The difficulty with this is you will have to do things like determining where the cursor should be, bringing up the virtual keyboard, and handling some of the other tasks that the EditField does for you.

这篇关于黑莓 - 面带笑容的文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆