Ecere SDK/eC Forums
http://ec-lang.org/community/
Print view

[Solved]How to change Label/EditBox text
http://ec-lang.org/community/viewtopic.php?f=5&t=154
Page 1 of 1
Author:  samsam598 [ Sat Aug 20, 2011 10:15 pm ]
Post subject:  [Solved]How to change Label/EditBox text

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;
      }
   };        
Author:  jerome [ Sun Aug 21, 2011 6:29 pm ]
Post subject:  Re: How to change Label/EditBox text

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
Author:  samsam598 [ Sun Aug 21, 2011 8:28 pm ]
Post subject:  Re: How to change Label/EditBox text

Hi Jerome,
Got it,thanks!
Author:  samsam598 [ Mon Aug 22, 2011 3:49 am ]
Post subject:  Re: How to change Label/EditBox text

just find that it is not so easy to set label.font property,esp. bold,underline etc.Please have a try and test.Thanks.
Author:  jerome [ Mon Aug 22, 2011 7:24 am ]
Post subject:  Re: How to change Label/EditBox text

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
Author:  jerome [ Tue Aug 23, 2011 1:21 am ]
Post subject:  Re: How to change Label/EditBox text

This has been fixed.

http://ecere.com/mantis/view.php?id=595

https://github.com/ecere/sdk/commit/f64 ... afffc651e3
Author:  samsam598 [ Tue Aug 23, 2011 1:46 am ]
Post subject:  Re: How to change Label/EditBox text

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.
Author:  jerome [ Tue Aug 23, 2011 10:26 am ]
Post subject:  Re: How to change Label/EditBox text

Hi Sam,

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

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

Regards,

Jerome
All times are UTC-05:00 Page 1 of 1