sahrear
24 messages 2009-02-21 |
Hi.. is it possible to have different font color in one screen? For example:
Screen screen = new Screen(); // create a Text widget to show some basic text Text text = new Text(); text.setAttribute("style", "color:red"); // set the Text of your object to "Hello World!" text.setText("Hello World!"); screen.add(text); Text text1 = new Text(); text1.setAttribute("style", "color:blue"); text1.setText("is the world blue?"); // add the text to the screen screen.add(text1);
// set the application current screen screen.setCurrent();
Or is ther any other way to have different font color in one text area?
|
|
nagkumar
51 messages 2009-02-22 |
A Screen taking text with varied font styles should be pefectly possible..But with in a text areas, if you need part of the input typed by the user to be in one color and other part in different color.. you may have to write your own custom widget of TextArea/TextFile and overide the paint() method... Not sure it this approach is right.. May be KUIX Dev team could add more insites to this.
Regards,
Raja Nagendra Kumar, C.T.O www.tejasoft.com
|
|
Tofu
Moderator
323 messages 2009-02-23 |
Yes Sahrear, your code is correct, except that the default layout of a screen is a gridlayout(1,1) then if you use it like this only the first text will be visible.
You need to add something like :
screen.parseAuthorStyle("layout:gridlayout(1,2)");
this is equals
screen.setAttribute("layout", "gridlayout(1,2)");
Else Nagkumar, no, it is not possible to have different colors in a textfield.
|
|
sahrear
24 messages 2009-02-24 |
Thanks tofu.. but my requirment is kind of like that as Nagkumar pointed..actually i believe i need a textfield.. for example:
String color1 = red;
String color2 = green;
textfield tfield = mew textField();
Text text1 = new Text();
text1.setAttribute("style", "color:"+color1);
tfield.add(text1);
Text text2 = new Text();
text2.setAttribute("style", "color:"+color1);
tfield.add(text2);
and finally
screen.add(tfield);
is it possible to do something like above? Or i can only show it in "screen" not in textfield? Please suggest, if it is not possible then i need to find out an work around.. thanks in advance..
 
|
|
sahrear
24 messages 2009-02-25 |
If i try nagkumar way of overridning paint() will it work?
Nagkumar, did you try it ever bro?
|
|
sahrear
24 messages 2009-02-25 |
Hi, Thanks you much for your response, but i'm getting confused more and more. Can you please give me a guideline? what i'm trying to do is: 1) Trying to make a simple SMS application
2) With 2 softbuttons in the bottom. Left one for 'send' right one for inserting color
2) When the user will try to write a new message then he will get two textfield. Such as: To:<textfield></textfield> Message:<textfield></textfield>
3) When he focuses the textfield for To: then he enters the receivers number. 4) Then he focuses to message textfield to write the message. Here comes my requirements: - Every times he selects the textfield he gets the default phone screen to write text. If he doesn't "insert" color then it writes in default. -if he inserts color (say red) then after writing the message in default phone screen, when it comes back to textfiled (focused) then it shown the entered text in red -same way, if he inserts the color blue,then after writing the text when textfield is focused (or any other way) then entered text will be blue. So thats all i wanted to do.. so can you please suggest? how should i approach to do this? what i understand is that, to take user input i must use some text holder kind of thing like textfield (like a form)... so i took textfield.. please give me a guideline.. What i understood from your mail that, it is not possible to render different font color in textfield.. so what i need to do is to take the string in one color (default) in textfiled and use something like preview and render the texts in different color possibly in "screen" and then try to send.. i understand that on receiver side there should be something to parse the tagging (<blue>blue text) and show it in different color. Please guide whether i''m in right track or not? Regards Sahrear
|
|
Tofu
Moderator
323 messages 2009-02-25 |
Actualy native Kuix TextField do not support multi text. Only textarea supports this but aren't editable. TextField arent realy editable because it open a J2ME native TextBox to enter text for full phone compatibility. Then i you want to use "direct input" you need to code it by your self.
The start point would be to create a custom widget that change a text value by overriding the processKeyEvent(byte type, int kuixKeyCode) method. This method is invoked by kuix if the widget is focused. Of course you custom widget need to extends FocusableWidget ...
|
|
sahrear
24 messages 2009-02-26 |
Hi tofu... what is the byte type here?
|
|
sahrear
24 messages 2009-02-26 |
Shouldn't i extend TextField? or FocusableWidget? If i want to override what is this parameter byte type?
|
|
Tofu
Moderator
323 messages 2009-02-27 |
byte type is a constant for event type. You can find then in KuixConstants :
// KeyEvent public static final byte KEY_PRESSED_EVENT_TYPE = 10; public static final byte KEY_RELEASED_EVENT_TYPE = 11; public static final byte KEY_REPEATED_EVENT_TYPE = 12;
Extends TextField or FocusableWidget ... It depends on how much code you want to rewrite and on how you want to do it. Th best way it maybe to extends TextField
|
|
sahrear
24 messages 2009-02-28 |
Dear Tofu.. i'm not that gud at coding.. so designed a work arround.. now i take the text input in a textfield and then "onchange" of textfield input i show the input in a textarea below with my customization :D i know thats not exactly i wanted but thats a gud alternative to me.. i will show u the codes shortly.. thanks..
|
|
hamditch.supcom
1 message 2009-03-16 |
Hi can anyone give me an example that explain how read a message in textfield . The text field is built by XML
XML code
<tabitem label="Pays"> <scrollPane style="layout:inlinelayout(false,fill);padding:15 ;gap : 10 10"> <text class="label" style="align:center; normal;color: #000000">Taper les premiers lettres de votrepays:</text> <textfield id="pays" constraints="url" >@{text}</textfield> <button onAction="recherche_pays" style="padding:1" shortcuts="2">%Rechercher%</button> <list></list> </scrollPane> </tabitem>
|
|
Tofu
Moderator
323 messages 2009-03-17 |
<button onAction="recherche_pays(#pays.text)" style="padding:1" shortcuts="2">%Rechercher%</button>
|
|