digitalmars.D.learn - Sorry -not getting anywhere with setText()
- June (2/2) May 07 2008 Attach what I am trying to make work -not winning here ,round and round ...
- Max Samukha (5/7) May 08 2008 You defined the setText(char[] name, char[] text) as nested function
- Max Samukha (47/54) May 08 2008 The following may have typos but should demonstrate the idea described
- June (2/72) May 08 2008 Hi & Thanks .. I tried this and adjusted a couple of lines in Main that ...
- Max Samukha (2/74) May 08 2008 The attached file is empty
- June (2/79) May 08 2008 This site seems slow ,I did not check Sorry
- Max Samukha (10/89) May 08 2008 Unlike in .NET winforms, you cannot set text for any control and
- Ary Borenszweig (30/33) May 08 2008 Why are you storing Text instances in an associative array and then
Attach what I am trying to make work -not winning here ,round and round in loops Any help appreciated
May 07 2008
On Thu, 08 May 2008 02:26:27 -0400, June <somewhere so.com> wrote:Attach what I am trying to make work -not winning here ,round and round in loops Any help appreciatedYou defined the setText(char[] name, char[] text) as nested function in Box's constructor. Move it out to the class' scope. Btw, 'public:' is not needed as class members are public by default.
May 08 2008
On Thu, 08 May 2008 10:36:20 +0300, Max Samukha <nospam nospam.com> wrote:On Thu, 08 May 2008 02:26:27 -0400, June <somewhere so.com> wrote:The following may have typos but should demonstrate the idea described in the previous thread: class Box { private Control[char[]] controls; // Use associative array this (Composite parent ,int style ) { auto box = new Composite(parent,DWT.SINGLE); box.setSize(700,40); auto No = new Text(box,DWT.LEFT); No.setBounds(1,15,10,15); No.setText(""); auto Date = new Text(box,DWT.LEFT); Date.setBounds( 21, 15, 60, 15); Date.setText(""); auto Content = new Text(box,DWT.LEFT); Content.setBounds( 90, 15,70, 15); Content.setText(""); box.setVisible = true; controls["No"]=No; controls["Date"]=Date; controls["Content"]=Content; box.setTabList(controls.values); } void setText(char[] name, char[] text) { controls[name].setText(text); } } void main () { Display display = new Display (); Shell shell = new Shell (display); shell.setText("Boxes"); Box mybox = new Box(shell,DWT.SINGLE); mybox.setText("No","wire"); mybox.setText("Content","Fishingline"); shell.pack(); shell.open(); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); }Attach what I am trying to make work -not winning here ,round and round in loops Any help appreciatedYou defined the setText(char[] name, char[] text) as nested function in Box's constructor. Move it out to the class' scope. Btw, 'public:' is not needed as class members are public by default.
May 08 2008
Max Samukha Wrote:On Thu, 08 May 2008 10:36:20 +0300, Max Samukha <nospam nospam.com> wrote:Hi & Thanks .. I tried this and adjusted a couple of lines in Main that I had wrong . Still get a compile error related to controls?On Thu, 08 May 2008 02:26:27 -0400, June <somewhere so.com> wrote:The following may have typos but should demonstrate the idea described in the previous thread: class Box { private Control[char[]] controls; // Use associative array this (Composite parent ,int style ) { auto box = new Composite(parent,DWT.SINGLE); box.setSize(700,40); auto No = new Text(box,DWT.LEFT); No.setBounds(1,15,10,15); No.setText(""); auto Date = new Text(box,DWT.LEFT); Date.setBounds( 21, 15, 60, 15); Date.setText(""); auto Content = new Text(box,DWT.LEFT); Content.setBounds( 90, 15,70, 15); Content.setText(""); box.setVisible = true; controls["No"]=No; controls["Date"]=Date; controls["Content"]=Content; box.setTabList(controls.values); } void setText(char[] name, char[] text) { controls[name].setText(text); } } void main () { Display display = new Display (); Shell shell = new Shell (display); shell.setText("Boxes"); Box mybox = new Box(shell,DWT.SINGLE); mybox.setText("No","wire"); mybox.setText("Content","Fishingline"); shell.pack(); shell.open(); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); }Attach what I am trying to make work -not winning here ,round and round in loops Any help appreciatedYou defined the setText(char[] name, char[] text) as nested function in Box's constructor. Move it out to the class' scope. Btw, 'public:' is not needed as class members are public by default.
May 08 2008
On Thu, 08 May 2008 04:35:18 -0400, June <somewhere so.com> wrote:Max Samukha Wrote:The attached file is emptyOn Thu, 08 May 2008 10:36:20 +0300, Max Samukha <nospam nospam.com> wrote:Hi & Thanks .. I tried this and adjusted a couple of lines in Main that I had wrong . Still get a compile error related to controls?On Thu, 08 May 2008 02:26:27 -0400, June <somewhere so.com> wrote:The following may have typos but should demonstrate the idea described in the previous thread: class Box { private Control[char[]] controls; // Use associative array this (Composite parent ,int style ) { auto box = new Composite(parent,DWT.SINGLE); box.setSize(700,40); auto No = new Text(box,DWT.LEFT); No.setBounds(1,15,10,15); No.setText(""); auto Date = new Text(box,DWT.LEFT); Date.setBounds( 21, 15, 60, 15); Date.setText(""); auto Content = new Text(box,DWT.LEFT); Content.setBounds( 90, 15,70, 15); Content.setText(""); box.setVisible = true; controls["No"]=No; controls["Date"]=Date; controls["Content"]=Content; box.setTabList(controls.values); } void setText(char[] name, char[] text) { controls[name].setText(text); } } void main () { Display display = new Display (); Shell shell = new Shell (display); shell.setText("Boxes"); Box mybox = new Box(shell,DWT.SINGLE); mybox.setText("No","wire"); mybox.setText("Content","Fishingline"); shell.pack(); shell.open(); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); }Attach what I am trying to make work -not winning here ,round and round in loops Any help appreciatedYou defined the setText(char[] name, char[] text) as nested function in Box's constructor. Move it out to the class' scope. Btw, 'public:' is not needed as class members are public by default.
May 08 2008
Max Samukha Wrote:On Thu, 08 May 2008 04:35:18 -0400, June <somewhere so.com> wrote:This site seems slow ,I did not check SorryMax Samukha Wrote:The attached file is emptyOn Thu, 08 May 2008 10:36:20 +0300, Max Samukha <nospam nospam.com> wrote:Hi & Thanks .. I tried this and adjusted a couple of lines in Main that I had wrong . Still get a compile error related to controls?On Thu, 08 May 2008 02:26:27 -0400, June <somewhere so.com> wrote:The following may have typos but should demonstrate the idea described in the previous thread: class Box { private Control[char[]] controls; // Use associative array this (Composite parent ,int style ) { auto box = new Composite(parent,DWT.SINGLE); box.setSize(700,40); auto No = new Text(box,DWT.LEFT); No.setBounds(1,15,10,15); No.setText(""); auto Date = new Text(box,DWT.LEFT); Date.setBounds( 21, 15, 60, 15); Date.setText(""); auto Content = new Text(box,DWT.LEFT); Content.setBounds( 90, 15,70, 15); Content.setText(""); box.setVisible = true; controls["No"]=No; controls["Date"]=Date; controls["Content"]=Content; box.setTabList(controls.values); } void setText(char[] name, char[] text) { controls[name].setText(text); } } void main () { Display display = new Display (); Shell shell = new Shell (display); shell.setText("Boxes"); Box mybox = new Box(shell,DWT.SINGLE); mybox.setText("No","wire"); mybox.setText("Content","Fishingline"); shell.pack(); shell.open(); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); }Attach what I am trying to make work -not winning here ,round and round in loops Any help appreciatedYou defined the setText(char[] name, char[] text) as nested function in Box's constructor. Move it out to the class' scope. Btw, 'public:' is not needed as class members are public by default.
May 08 2008
On Thu, 08 May 2008 05:53:22 -0400, June <somewhere so.com> wrote:Max Samukha Wrote:Unlike in .NET winforms, you cannot set text for any control and Control class does not have a setText property so if you don't plan to use other controls than Text, declare the value type of the associative array to be Text. Also I'm not sure that Composite has a setTabList property. Please consult SWT reference. And if I understand correctly you are going to use lots of textboxes. If you are going to present a list or tabular data, it would be better for performance and yourself to use a grid or list control whatever is appropriate and available in DWT.On Thu, 08 May 2008 04:35:18 -0400, June <somewhere so.com> wrote:This site seems slow ,I did not check SorryMax Samukha Wrote:The attached file is emptyOn Thu, 08 May 2008 10:36:20 +0300, Max Samukha <nospam nospam.com> wrote:Hi & Thanks .. I tried this and adjusted a couple of lines in Main that I had wrong . Still get a compile error related to controls?On Thu, 08 May 2008 02:26:27 -0400, June <somewhere so.com> wrote:The following may have typos but should demonstrate the idea described in the previous thread: class Box { private Control[char[]] controls; // Use associative array this (Composite parent ,int style ) { auto box = new Composite(parent,DWT.SINGLE); box.setSize(700,40); auto No = new Text(box,DWT.LEFT); No.setBounds(1,15,10,15); No.setText(""); auto Date = new Text(box,DWT.LEFT); Date.setBounds( 21, 15, 60, 15); Date.setText(""); auto Content = new Text(box,DWT.LEFT); Content.setBounds( 90, 15,70, 15); Content.setText(""); box.setVisible = true; controls["No"]=No; controls["Date"]=Date; controls["Content"]=Content; box.setTabList(controls.values); } void setText(char[] name, char[] text) { controls[name].setText(text); } } void main () { Display display = new Display (); Shell shell = new Shell (display); shell.setText("Boxes"); Box mybox = new Box(shell,DWT.SINGLE); mybox.setText("No","wire"); mybox.setText("Content","Fishingline"); shell.pack(); shell.open(); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); }Attach what I am trying to make work -not winning here ,round and round in loops Any help appreciatedYou defined the setText(char[] name, char[] text) as nested function in Box's constructor. Move it out to the class' scope. Btw, 'public:' is not needed as class members are public by default.
May 08 2008
June wrote:Attach what I am trying to make work -not winning here ,round and round in loops Any help appreciatedWhy are you storing Text instances in an associative array and then accessing them by name? You are doing: Box mybox = new Box(shell,DWT.SINGLE); mybox.setText("No","wire"); mybox.setText("Content","Fishingline"); Than means that you know that Box has a "No" and "Content" Text. I recommend you to store them as public fields of Box class (or as properties, it's almost the same): class Box { Text No; Text Date; Text Content; public: this (Composite parent ,int style ) { // ... No = new Text(box,DWT.LEFT); Date = new Text(box,DWT.LEFT); Content = new Text(box,DWT.LEFT); // ... } } That way, if you mistype "Content", "No" or "Date", you'll get a compile error, while in your approach, you'll get a runtime error. And also, if you use an IDE that offers autocompletion, you can do "box." and get No, Date and Content as suggestions. The setText method, in this case, should be: void setText(Text control, char[] text) { control.setText(text); }
May 08 2008