[Solved]How to change Label/EditBox text

General help with the Ecere Cross Platform GUI toolkit: Window, common controls, events, etc.
Help with the 2D Graphics library: Surface, Display, Bitmap, Font and others.
Post Reply
samsam598
Posts: 212
Joined: Thu Apr 14, 2011 9:44 pm

[Solved]How to change Label/EditBox text

Post by samsam598 »

Hello!Given below code,the editBox2.text and label1.text does not change to editBox1.text,why?And how to make it?Thanks for the help.

Code: Select all

EditBox editBox1 { this, size = { 486, 19 }, position = { 24, 16 } }; 
   EditBox editBox2 { this, text = "editBox2", foreground = green, font = { "Times New Roman", 26 }, size = { 478, 59 }, position = { 32, 120 } };
   Label label1 { this, text = "label1", foreground = orangeRed, font = { "Times New Roman", 26 }, size = { 516, 53 }, position = { 32, 48 } };
   Button btnShow 
   {
      this, text = "(O)显示", altO, size = { 68, 29 }, position = { 240, 200 };

      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
      {
         this.editBox2.text=this.editBox1.text;
         this.label1.text=this.editBox1.text;
         return true;
      }
   };        
Last edited by samsam598 on Tue Aug 23, 2011 8:23 pm, edited 2 times in total.
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: How to change Label/EditBox text

Post by jerome »

Hi Sam,

I need to clarify these properties.

What the user types inside the editBox is accessed (changed or retrieved) through the 'contents' property.
For all windows and controls, 'text' is the caption (The text that shows in the title bar, if it has one). We plan to rename this property to 'caption' in the future to avoid this confusion. For controls, the 'text' property can be used to label them, i.e. the label will be connected to the control (through the 'labeledWindow' property) and will name itself from the control. (For the label to use the text of the control, its own (the label's) 'text' property must not be set.)

One advantage of this is that when you click on the label it will activate the labeled control. The hotKey of the control will also be underlined on the label.

Here is an example of how to set this up:

Code: Select all

import "ecere"
 
class Form1 : Window
{
   text = "Form1";
   background = activeBorder;
   borderStyle = sizable;
   hasMaximize = true;
   hasMinimize = true;
   hasClose = true;
   size = { 576, 432 };
 
   EditBox editBox1 { this, text = "EditBox1", hotKey = altE, size = { 486, 19 }, position = { 32, 32 } };
   Label lblEditBox1 { this, position = { 32, 8 }, labeledWindow = editBox1 };
   EditBox editBox2 { this, foreground = green, font = { "Times New Roman", 26 }, size = { 478, 59 }, position = { 32, 136 } };
   Label label1 { this, text = "label1", foreground = orangeRed, font = { "Times New Roman", 26 }, size = { 516, 53 }, position = { 32, 72 } };
   Button btnShow
   {
      this, text = "(O)显示", altO, size = { 68, 29 }, position = { 240, 216 };
 
      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
      {
        editBox2.contents=editBox1.contents;
        label1.text=editBox1.contents;
        return true;
      }
   };
}
 
Form1 form1 {};
Regards,

Jerome
samsam598
Posts: 212
Joined: Thu Apr 14, 2011 9:44 pm

Re: How to change Label/EditBox text

Post by samsam598 »

Hi Jerome,
Got it,thanks!
samsam598
Posts: 212
Joined: Thu Apr 14, 2011 9:44 pm

Re: How to change Label/EditBox text

Post by samsam598 »

just find that it is not so easy to set label.font property,esp. bold,underline etc.Please have a try and test.Thanks.
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: How to change Label/EditBox text

Post by jerome »

Hi Sam.

This is a known issue in the current source.
I'll try to take a look at it today. Thanks.
All these little bugs need to be fixed before we can release 0.44pre2 :)

Jerome
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: How to change Label/EditBox text

Post by jerome »

samsam598
Posts: 212
Joined: Thu Apr 14, 2011 9:44 pm

Re: How to change Label/EditBox text

Post by samsam598 »

Thanks for the update.Could you please let me know which download is the latest snapshot since 1:00am afterwards today?I have no git installed as this is a public pc.

Thanks.
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: How to change Label/EditBox text

Post by jerome »

Hi Sam,

https://github.com/ecere/sdk/zipball/master

Is always an up to date link to the latest snapshot.

Regards,

Jerome
Post Reply