April 22, 2008
Barry Denton wrote:
> Bill Baxter Wrote:
> 
>> Barry Denton wrote:
>>> Barry Denton Wrote:
>>>
>>>> Jarrett Billingsley Wrote:
>>>>
>>>>> "Barry Denton" <basse42@yahoo.com> wrote in message news:fubgb0$22go$1@digitalmars.com...
>>>>>> I have a Listener added to a button as so :-
>>>>>>
>>>>>> button.addListener(DWT.Selection, new class Listener {
>>>>>>        void handleEvent(Event event) {
>>>>>>            itemWords [5] = "item has changed " ;//~ System.currentTimeMillis();
>>>>>>            minitable.clear(5);  }  });
>>>>>>
>>>>>> When pressed the button outputs this:-
>>>>>>
>>>>>> Event {missing or misplaced '}'}Event {type=13 Button {Change item} time=1679601378 data={null} x=0 y=0 width=0 height=0 detail=0}
>>>>>> .
>>>>>> Now all is as it should be except for the  {missing or misplaced '}'}
>>>>> Tango's formatting uses a pair of curly braces like "{}".  Your output is supposed to go "{Event {type=13....", but Tango sees the opening '{', tries to parse it as a format specifier, and fails, leaving you with an error message embedded in the output.
>>>>>
>>>>> The question I have is: where is this output being generated?  This code doesn't seem to generate it.
>>>>>
>>>>> I ask because it's a simple fix: instead of doing something like "Stdout.formatln(x.toString())", just use "Stdout.formatln("{}", x)", that is, escape the string by making it a parameter to be formatted. 
>>>>>
>>>>>
>>>> Thanks but this did not work .Did I mess it up?
>>>>  button.addListener(DWT.Selection, new class Listener {
>>>>         void handleEvent(Event event) {
>>>>             itemWords [5] = ("item has changed " ~ clock.stringof~"  "~ cast(char)clock);
>>>>             Stdout.formatln("{}""{}" ,event.mangleof, event.stringof).newline;
>>>>             Stdout.formatln("{}""{}" ,clock.mangleof, clock.stringof).newline;
>>>>             Stdout.print(itemWords).newline;
>>>>             minitable.clear(5); 
>>>>
>>> Tried this but still there
>>>
>>> button.addListener(DWT.Selection, new class Listener {
>>>         void handleEvent(Event event) {
>>>             itemWords [5] = ("item has changed " ~ clock.stringof~"  "~ cast(char)clock);
>>>             Stdout.formatln("{}""{}" ,event.mangleof, event.stringof).newline;
>>>             Stdout.formatln("{}""{}" ,clock.mangleof, clock.stringof).newline;
>>>             Stdout.formatln("{}",event);
>>>             Stdout.print(itemWords).newline;
>>>             minitable.clear(5); Output
>>> C3dwt7widgets5Event5Eventevent
>>>
>>> PS5tango4time9WallClock9WallClockclock
>>>
>>> Event {missing or misplaced '}'}Event {type=13 Button {Change item at index 5} time=1753196186 data={null} x=0 y=0 width=0 height=0 detail=0}
>>> [ item 0  , item 1  , item 2  , item 3  , item 4  , item has changed clock  , item 6  , item 7  , item 8  , item 9   ]
>>> Event {missing or misplaced '}'}Event {type=36 Table {} time=1753196186 data={null} x=0 y=0 width=0 height=0 detail=0}
>>>
>> The problem is in dwt's dwt/widgets/Event.d, toString method:
>>
>> override public char[] toString () {
>>      return Format( "Event {type={} {} time={} data={} x={} y={} width={} height={} detail={}}",
>>          type, widget, time, data, x, y, width, height, detail ); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
>> }
>>
>> It needs to escape the first and last '{'s.
>> Can you fix it, Frank?
>>
>> --bb
> Will result be rest of  fields then filled in ?

I dunno.  Looks like Frank checked in the fix.  Just update and try it.

--bb
April 22, 2008
Bill Baxter Wrote:

> Barry Denton wrote:
> > Bill Baxter Wrote:
> > 
> >> Barry Denton wrote:
> >>> Barry Denton Wrote:
> >>>
> >>>> Jarrett Billingsley Wrote:
> >>>>
> >>>>> "Barry Denton" <basse42@yahoo.com> wrote in message news:fubgb0$22go$1@digitalmars.com...
> >>>>>> I have a Listener added to a button as so :-
> >>>>>>
> >>>>>> button.addListener(DWT.Selection, new class Listener {
> >>>>>>        void handleEvent(Event event) {
> >>>>>>            itemWords [5] = "item has changed " ;//~
> >>>>>> System.currentTimeMillis();
> >>>>>>            minitable.clear(5);  }  });
> >>>>>>
> >>>>>> When pressed the button outputs this:-
> >>>>>>
> >>>>>> Event {missing or misplaced '}'}Event {type=13 Button {Change item}
> >>>>>> time=1679601378 data={null} x=0 y=0 width=0 height=0 detail=0}
> >>>>>> .
> >>>>>> Now all is as it should be except for the  {missing or misplaced '}'}
> >>>>> Tango's formatting uses a pair of curly braces like "{}".  Your output is supposed to go "{Event {type=13....", but Tango sees the opening '{', tries to parse it as a format specifier, and fails, leaving you with an error message embedded in the output.
> >>>>>
> >>>>> The question I have is: where is this output being generated?  This code doesn't seem to generate it.
> >>>>>
> >>>>> I ask because it's a simple fix: instead of doing something like "Stdout.formatln(x.toString())", just use "Stdout.formatln("{}", x)", that is, escape the string by making it a parameter to be formatted.
> >>>>>
> >>>>>
> >>>> Thanks but this did not work .Did I mess it up?
> >>>>  button.addListener(DWT.Selection, new class Listener {
> >>>>         void handleEvent(Event event) {
> >>>>             itemWords [5] = ("item has changed " ~ clock.stringof~"  "~ cast(char)clock);
> >>>>             Stdout.formatln("{}""{}" ,event.mangleof, event.stringof).newline;
> >>>>             Stdout.formatln("{}""{}" ,clock.mangleof, clock.stringof).newline;
> >>>>             Stdout.print(itemWords).newline;
> >>>>             minitable.clear(5);
> >>>>
> >>> Tried this but still there
> >>>
> >>> button.addListener(DWT.Selection, new class Listener {
> >>>         void handleEvent(Event event) {
> >>>             itemWords [5] = ("item has changed " ~ clock.stringof~"  "~ cast(char)clock);
> >>>             Stdout.formatln("{}""{}" ,event.mangleof, event.stringof).newline;
> >>>             Stdout.formatln("{}""{}" ,clock.mangleof, clock.stringof).newline;
> >>>             Stdout.formatln("{}",event);
> >>>             Stdout.print(itemWords).newline;
> >>>             minitable.clear(5);
> >>> Output
> >>> C3dwt7widgets5Event5Eventevent
> >>>
> >>> PS5tango4time9WallClock9WallClockclock
> >>>
> >>> Event {missing or misplaced '}'}Event {type=13 Button {Change item at index 5} time=1753196186 data={null} x=0 y=0 width=0 height=0 detail=0}
> >>> [ item 0  , item 1  , item 2  , item 3  , item 4  , item has changed clock  , item 6  , item 7  , item 8  , item 9   ]
> >>> Event {missing or misplaced '}'}Event {type=36 Table {} time=1753196186 data={null} x=0 y=0 width=0 height=0 detail=0}
> >>>
> >> The problem is in dwt's dwt/widgets/Event.d, toString method:
> >>
> >> override public char[] toString () {
> >>      return Format( "Event {type={} {} time={} data={} x={} y={}
> >> width={} height={} detail={}}",
> >>          type, widget, time, data, x, y, width, height, detail );
> >> //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
> >> //$NON-NLS-6$ //$NON-NLS-7$
> >> }
> >>
> >> It needs to escape the first and last '{'s.
> >> Can you fix it, Frank?
> >>
> >> --bb
> > Will result be rest of  fields then filled in ?
> 
> I dunno.  Looks like Frank checked in the fix.  Just update and try it.
> 
> --bb
Sorry for being pest but it  not working
Frank escape the first curly bracket but that fixed nothing
Problems seem with Event . Does not fill in fields as should  when pass event.
I see missing bracket is not really important . My mistake .
Important get return of needed fields which cannot happen.
April 22, 2008
Barry Denton wrote:
> Bill Baxter Wrote:
> 
>> Barry Denton wrote:
>>> Bill Baxter Wrote:
>>>
>>>> Barry Denton wrote:
>>>>> Barry Denton Wrote:
>>>>>
>>>>>> Jarrett Billingsley Wrote:
>>>>>>
>>>>>>> "Barry Denton" <basse42@yahoo.com> wrote in message news:fubgb0$22go$1@digitalmars.com...
>>>>>>>> I have a Listener added to a button as so :-
>>>>>>>>
>>>>>>>> button.addListener(DWT.Selection, new class Listener {
>>>>>>>>        void handleEvent(Event event) {
>>>>>>>>            itemWords [5] = "item has changed " ;//~ System.currentTimeMillis();
>>>>>>>>            minitable.clear(5);  }  });
>>>>>>>>
>>>>>>>> When pressed the button outputs this:-
>>>>>>>>
>>>>>>>> Event {missing or misplaced '}'}Event {type=13 Button {Change item} time=1679601378 data={null} x=0 y=0 width=0 height=0 detail=0}
>>>>>>>> .
>>>>>>>> Now all is as it should be except for the  {missing or misplaced '}'}
>>>>>>> Tango's formatting uses a pair of curly braces like "{}".  Your output is supposed to go "{Event {type=13....", but Tango sees the opening '{', tries to parse it as a format specifier, and fails, leaving you with an error message embedded in the output.
>>>>>>>
>>>>>>> The question I have is: where is this output being generated?  This code doesn't seem to generate it.
>>>>>>>
>>>>>>> I ask because it's a simple fix: instead of doing something like "Stdout.formatln(x.toString())", just use "Stdout.formatln("{}", x)", that is, escape the string by making it a parameter to be formatted. 
>>>>>>>
>>>>>>>
>>>>>> Thanks but this did not work .Did I mess it up?
>>>>>>  button.addListener(DWT.Selection, new class Listener {
>>>>>>         void handleEvent(Event event) {
>>>>>>             itemWords [5] = ("item has changed " ~ clock.stringof~"  "~ cast(char)clock);
>>>>>>             Stdout.formatln("{}""{}" ,event.mangleof, event.stringof).newline;
>>>>>>             Stdout.formatln("{}""{}" ,clock.mangleof, clock.stringof).newline;
>>>>>>             Stdout.print(itemWords).newline;
>>>>>>             minitable.clear(5); 
>>>>>>
>>>>> Tried this but still there
>>>>>
>>>>> button.addListener(DWT.Selection, new class Listener {
>>>>>         void handleEvent(Event event) {
>>>>>             itemWords [5] = ("item has changed " ~ clock.stringof~"  "~ cast(char)clock);
>>>>>             Stdout.formatln("{}""{}" ,event.mangleof, event.stringof).newline;
>>>>>             Stdout.formatln("{}""{}" ,clock.mangleof, clock.stringof).newline;
>>>>>             Stdout.formatln("{}",event);
>>>>>             Stdout.print(itemWords).newline;
>>>>>             minitable.clear(5); Output
>>>>> C3dwt7widgets5Event5Eventevent
>>>>>
>>>>> PS5tango4time9WallClock9WallClockclock
>>>>>
>>>>> Event {missing or misplaced '}'}Event {type=13 Button {Change item at index 5} time=1753196186 data={null} x=0 y=0 width=0 height=0 detail=0}
>>>>> [ item 0  , item 1  , item 2  , item 3  , item 4  , item has changed clock  , item 6  , item 7  , item 8  , item 9   ]
>>>>> Event {missing or misplaced '}'}Event {type=36 Table {} time=1753196186 data={null} x=0 y=0 width=0 height=0 detail=0}
>>>>>
>>>> The problem is in dwt's dwt/widgets/Event.d, toString method:
>>>>
>>>> override public char[] toString () {
>>>>      return Format( "Event {type={} {} time={} data={} x={} y={} width={} height={} detail={}}",
>>>>          type, widget, time, data, x, y, width, height, detail ); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
>>>> }
>>>>
>>>> It needs to escape the first and last '{'s.
>>>> Can you fix it, Frank?
>>>>
>>>> --bb
>>> Will result be rest of  fields then filled in ?
>> I dunno.  Looks like Frank checked in the fix.  Just update and try it.
>>
>> --bb
> Sorry for being pest but it  not working
> Frank escape the first curly bracket but that fixed nothing Problems seem with Event . Does not fill in fields as should  when pass event.
> I see missing bracket is not really important . My mistake .
> Important get return of needed fields which cannot happen.

Which fields do you need?  Event is a generic event type that covers a lot of different kinds of events.  So not all the fields are relevant all the time.  The non-relevant fields will just will just contain garbage.  Like x,y,width,height -- those aren't relevant to a Button click.  But event.widget should be a valid reference to the Button widget that was clicked.

--bb
April 23, 2008
Thanks Bill  I have typed listeners in tables  which are SetData and Selection type listeners. They should return  TableItem number and  x , y, point to identify them i think so.

They do not , can not work on table to change cells


April 24, 2008
Barry Denton Wrote:

> Thanks Bill  I have typed listeners in tables  which are SetData and Selection type listeners. They should return  TableItem number and  x , y, point to identify them i think so.
> 
> They do not , can not work on table to change cells
> 
> 


I had a look at this too . I notice TableEditor has to produce its own sources for the cell identification.  See the below -I couldn't get the item no to go into table so I changed it a bit . This example is given  in the TextEditor.d file itself

module testTableEditor;
import dwt.DWT;
import dwt.widgets.Display;
import dwt.widgets.Shell;
import dwt.widgets.Table;
import dwt.widgets.TableColumn;
import dwt.widgets.TableItem;
import dwt.layout.GridLayout;
import dwt.custom.TableEditor;
import tango.util.Convert;
import tango.io.Stdout;
import TextUtil = tango.text.Util;
import dwt.events.SelectionEvent;
import dwt.events.SelectionListener;
import dwt.events.SelectionAdapter;
import dwt.events.ModifyListener;
import dwt.widgets.Control;
import dwt.widgets.Text;



void main () {
  Display display = new Display ();
  Shell shell = new Shell (display);
  shell.setText("Test TableEditor");
  GridLayout gridLayout = new GridLayout();
  shell.setLayout(gridLayout);

   final Table table = new Table(shell, DWT.FULL_SELECTION | DWT.HIDE_SELECTION);
   TableColumn column1 = new TableColumn(table, DWT.NONE);
   TableColumn column2 = new TableColumn(table, DWT.NONE);
   for (int i = 0; i < 10; i++) {
       TableItem item = new TableItem(table, DWT.NONE);
       char[][] needed = [ "item" , "edit this value" ];
       item.setText(needed);
      //item.setText(new char[][] {"item " + i, "edit this value"});original line
   }
   column1.pack();
   column2.pack();

   final TableEditor
   editor = new TableEditor(table);
   //The editor must have the same size as the cell and must
   //not be any smaller than 50 pixels.
   editor.horizontalAlignment = DWT.LEFT;
   editor.grabHorizontal = true;
   editor.minimumWidth = 50;
   // editing the second column
   final int EDITABLECOLUMN = 1;

   table.addSelectionListener(new class SelectionAdapter {
       public void widgetSelected(SelectionEvent e) {
           Stdout.print(e).newline;
// Clean up any previous editor control
           Control oldEditor = editor.getEditor();
           if (oldEditor !is null) oldEditor.dispose();
           // Identify the selected row
           TableItem item = cast (TableItem)e.item;
           if (item is null) return;
           // The control that will be the editor must be a child of the Table
           Text newEditor = new Text(table, DWT.NONE);
           newEditor.setText(item.getText(EDITABLECOLUMN));
           newEditor.addModifyListener(new class ModifyListener {
               public void modifyText(ModifyEvent e) {
                   Text text = cast (Text)editor.getEditor();
                   editor.getItem().setText(EDITABLECOLUMN, text.getText());
               }           }    );
           newEditor.selectAll();
           newEditor.setFocus();
           editor.setEditor(newEditor, item, EDITABLECOLUMN);
       }
   });


April 24, 2008
Barry Denton Wrote:

> Thanks Bill  I have typed listeners in tables  which are SetData and Selection type listeners. They should return  TableItem number and  x , y, point to identify them i think so.
> 
> They do not , can not work on table to change cells
> 
> 


I had a look at this too . I notice TableEditor has to produce its own sources for the cell identification.  See the below -I couldn't get the item no to go into table so I changed it a bit . This example is given  in the TextEditor.d file itself

module testTableEditor;
import dwt.DWT;
import dwt.widgets.Display;
import dwt.widgets.Shell;
import dwt.widgets.Table;
import dwt.widgets.TableColumn;
import dwt.widgets.TableItem;
import dwt.layout.GridLayout;
import dwt.custom.TableEditor;
import tango.util.Convert;
import tango.io.Stdout;
import TextUtil = tango.text.Util;
import dwt.events.SelectionEvent;
import dwt.events.SelectionListener;
import dwt.events.SelectionAdapter;
import dwt.events.ModifyListener;
import dwt.widgets.Control;
import dwt.widgets.Text;



void main () {
  Display display = new Display ();
  Shell shell = new Shell (display);
  shell.setText("Test TableEditor");
  GridLayout gridLayout = new GridLayout();
  shell.setLayout(gridLayout);

   final Table table = new Table(shell, DWT.FULL_SELECTION | DWT.HIDE_SELECTION);
   TableColumn column1 = new TableColumn(table, DWT.NONE);
   TableColumn column2 = new TableColumn(table, DWT.NONE);
   for (int i = 0; i < 10; i++) {
       TableItem item = new TableItem(table, DWT.NONE);
       char[][] needed = [ "item" , "edit this value" ];
       item.setText(needed);
      //item.setText(new char[][] {"item " + i, "edit this value"});original line
   }
   column1.pack();
   column2.pack();

   final TableEditor
   editor = new TableEditor(table);
   //The editor must have the same size as the cell and must
   //not be any smaller than 50 pixels.
   editor.horizontalAlignment = DWT.LEFT;
   editor.grabHorizontal = true;
   editor.minimumWidth = 50;
   // editing the second column
   final int EDITABLECOLUMN = 1;

   table.addSelectionListener(new class SelectionAdapter {
       public void widgetSelected(SelectionEvent e) {
           Stdout.print(e).newline;
// Clean up any previous editor control
           Control oldEditor = editor.getEditor();
           if (oldEditor !is null) oldEditor.dispose();
           // Identify the selected row
           TableItem item = cast (TableItem)e.item;
           if (item is null) return;
           // The control that will be the editor must be a child of the Table
           Text newEditor = new Text(table, DWT.NONE);
           newEditor.setText(item.getText(EDITABLECOLUMN));
           newEditor.addModifyListener(new class ModifyListener {
               public void modifyText(ModifyEvent e) {
                   Text text = cast (Text)editor.getEditor();
                   editor.getItem().setText(EDITABLECOLUMN, text.getText());
               }           }    );
           newEditor.selectAll();
           newEditor.setFocus();
           editor.setEditor(newEditor, item, EDITABLECOLUMN);
       }
   });


April 25, 2008
Tower Ty wrote:
> Barry Denton Wrote:
> 
>> Thanks Bill  I have typed listeners in tables  which are SetData and Selection type listeners.
>> They should return  TableItem number and  x , y, point to identify them i think so.
>>
>> They do not , can not work on table to change cells
>>
>>
> 
> 
> I had a look at this too . 

Great.  Then maybe you and Barry can work together to figure it out.

--bb
April 26, 2008
Try this Its a twist on rock,stone,scissors game and gives x & y of mouse downs


1 2
Next ›   Last »