D - Event (Dig)
- Phill (177/177) Jan 23 2004 Does anyone know how to get the Object
- Burton Radons (48/71) Jan 25 2004 I'm afraid that while that was always in the plan, I never got around to...
- Phill (7/78) Jan 25 2004 Thanks Burton!
Does anyone know how to get the Object source of an Event, in Dig. ie: Button b; //later on with(b = new Button("1")){ onClick(handleEvent()); } // later on handleEvent(Event event){ //now how do I get the Object source and // string from the button from the parameter } I have made a simple calculator with 18 buttons, at the moment I have a function to handle each buttons event ie: 18 Event functions. Code attached. Phill. begin 666 DCalc.d M+R\ *BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ M- T*+R\ 0W)E871E9"!">2!0:&EL;"!4:&]R<&4-"B\O(%1H:7, <')O9W)A M;2!I<R!A('9E<GD 8F%S:6, 8V%L8W5L871O<BP =&\ :&5L<"!M92 -"B\O M9V5T(&%Q=6%I;G1E9"!W:71H($0L($1)1$4 86YD('1H92!$24< 1U5)(&]N M+U-P96-I86P =&AA;FMS('1O('1H92!P96]P;&4 =&AA="!A;G-W97)E9"!M M"B\O(&1?;&%B0'EA:&]O9W)O=7!S+F-O;0T*+R\ *BHJ*BHJ*BHJ*BHJ*BHJ M*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BH-"FEM<&]R="!N M970N0G5R=&]N4F%D;VYS+F1I9RYM86EN.PT*:6UP;W)T(&YE="Y"=7)T;VY2 M+"!F:79E+"!S:7 L('-E=F5N+"!E:6=H="P ;FEN92P >F5R;RP <&QU<RP M;6EN=7,L('1I;65S+"!D:79I9&4L(&UO9"P <&5R:6]D+"!E<6PL(&-L<CL- M8F5R(#T M:65W(#H 1G)A;64-"B >PT*"0T*"0D)"0T*(" (" =&AI<R H*0T*(" M(" >PT*(" (" (" (&-A<'1I;VX *")$0V%L8R(I.PT*"0D)=VED=& H M,30X*3L-" D)"6AE:6=H=" Q-3 I.PT*"0D)<F5S:7IA8FQE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](&YE=R!"=71T;VXH=&AI<RDI>PT*(" (" (" M" D)"7-T:6-K>2 B/#Y>=B(I.PT*"0D)8F]R9&5R960 *'1R=64I.PT*"0D) M*'1I;65S(#T M(#T M9&]$:79I9&4I.PT*"0D (" ?0T*"0D-" D)"7=I=& *&-L<B ](&YE=R!" M+ DR+" R*3L-" D)"7-T:6-K>2 B/#XB*3L-" D)"6]N0VQI8VLN861D*"9D M"G9O:60 9&]&;W5R*$5V96YT(&4I>R -" D)(" (" ("!E9"YT97AT*&%P M9&]3:7 H179E;G0 92E[( T*"0D (" (" (&5D+G1E>'0H87!P96YD*&5D M*$5V96YT(&4I>R -" D)(" (" ("!E9"YT97AT*&%P<&5N9"AE9"YT97AT M*"DL("(Y(BDI.PD-" D)"0D-" D)"0D ?0T*"0D)"0T*=F]I9"!D;UIE<F\H M179E;G0 92E[( T*"0D (" (" (&5D+G1E>'0H87!P96YD*&5D+G1E>'0H M*$5V96YT(&4I>R -" D)(" (" ("!E9"YT97AT*&%P<&5N9"AE9"YT97AT M*"DL("(N(BDI.PD-" D)"0D-" D)"0D ?0T*"0D)"0T*=F]I9"!D;TUO9" I M=" ](&9A;'-E.PT*"0EF:7)S=$YU;6)E<B ](&%T;V8H960N=&5X=" I*3L- M" D)?0T*"6]P(#T (B4B.PT*"2!]"0D-" D-"G9O:60 9&]0;'5S*"E[( T* M"69I<G-T(#T M<FEN=&8H(B5F(BP 9FER<W1.=6UB97(I.PT*"7!R:6YT9B B7&XB*3L-" ED M(#T M*"E[( T*"69I<G-T(#T M=F]I9"!D;T1I=FED92 I>R -" EF:7)S=" ](&9A;'-E.PT*"6]P(#T (B\B M.PT*"69I<G-T3G5M8F5R(#T 871O9BAE9"YT97AT*"DI.PT*"61O0VQE87(H M(&%T;V8H960N=&5X=" I*3L-" EP<FEN=&8H(B5F(BP <V5C;VYD3G5M8F5R M.PT*"69I<G-T3G5M8F5R(#T <V5C;VYD3G5M8F5R.PT*"2!]"0D-" D)"0D- M*R(I>R -" D)<F5S=6QT(#T 9FER<W1.=6UB97( *R!S96-O;F1.=6UB97([ M"7!R:6YT9B B)68B+"!S96-O;F1.=6UB97(I.PT*"0EP<FEN=&8H(EQN<F5S M=6QT/2(I.PT*"0EP<FEN=&8H(B5F(BP <F5S=6QT*3L-" D)9&ES<&QA>5)E M<W5L=" I(#L- M<W5L=" ](&9I<G-T3G5M8F5R("T <V5C;VYD3G5M8F5R.PT*"0ED:7-P;&%Y M4F5S=6QT*"D .PT*"0E]( T*"65L<V4-" EI9BAO<" ]/2 B*B(I>R -" D) M<F5S=6QT(#T M"0ER97-U;'0 /2!F:7)S=$YU;6)E<B O('-E8V]N9$YU;6)E<CL-" D)9&ES M<&QA>5)E<W5L=" I(#L-" D)?0T*"65L<V4-" EI9BAO<" ]/2 B)2(I>R - M" D)<F5S=6QT(#T M($]015)!5$]2(%-014-)1DE%1"(I.PT*"0D-"GT-" T*=F]I9"!D:7-P;&%Y M4F5S=6QT*"E[( T*"6-H87( 8VA;,3 Q73L-"B ("!S<')I;G1F*&-H+" B M)4<B+"!R97-U;'0I.PT*"65D+G1E>'0H8V I.PT*"2!]"0D)"0T*"0T*8VAA ` end
Jan 23 2004
Phill wrote:Does anyone know how to get the Object source of an Event, in Dig. ie: Button b; //later on with(b = new Button("1")){ onClick(handleEvent()); } // later on handleEvent(Event event){ //now how do I get the Object source and // string from the button from the parameter } I have made a simple calculator with 18 buttons, at the moment I have a function to handle each buttons event ie: 18 Event functions. Code attached.I'm afraid that while that was always in the plan, I never got around to it. However, it's easy to do what you want in this case. Just have something like this: class AppendFunction { char [] text; /**< Text to append. */ this (char [] text) { this.text = text; } void event (Event event) { ed.text (append (ed.text (), text)); } } void doView () { int c, r = 1; void createNumericButton (char [] text) { with (new Button (this)) { caption (" &" ~ text ~ " "); grid (c ++, r, 1, 1); sticky ("<>^v"); bordered (true); onClick.add (&(new AppendFunction (text)).event); } } void nextRow () { c = 0, r ++; } createNumericButton ("1"); createNumericButton ("2"); createNumericButton ("3"); nextRow (); createNumericButton ("5"); createNumericButton ("6"); createNumericButton ("7"); nextRow (); createNumericButton ("8"); createNumericButton ("9"); createNumericButton ("0"); nextRow (); ... }
Jan 25 2004
Thanks Burton! That works great, it will also be a great help in the future. Phill. "Burton Radons" <loth users.sourceforge.net> wrote in message news:buvvru$1l98$1 digitaldaemon.com...Phill wrote:it.Does anyone know how to get the Object source of an Event, in Dig. ie: Button b; //later on with(b = new Button("1")){ onClick(handleEvent()); } // later on handleEvent(Event event){ //now how do I get the Object source and // string from the button from the parameter } I have made a simple calculator with 18 buttons, at the moment I have a function to handle each buttons event ie: 18 Event functions. Code attached.I'm afraid that while that was always in the plan, I never got around toHowever, it's easy to do what you want in this case. Just have something like this: class AppendFunction { char [] text; /**< Text to append. */ this (char [] text) { this.text = text; } void event (Event event) { ed.text (append (ed.text (), text)); } } void doView () { int c, r = 1; void createNumericButton (char [] text) { with (new Button (this)) { caption (" &" ~ text ~ " "); grid (c ++, r, 1, 1); sticky ("<>^v"); bordered (true); onClick.add (&(new AppendFunction (text)).event); } } void nextRow () { c = 0, r ++; } createNumericButton ("1"); createNumericButton ("2"); createNumericButton ("3"); nextRow (); createNumericButton ("5"); createNumericButton ("6"); createNumericButton ("7"); nextRow (); createNumericButton ("8"); createNumericButton ("9"); createNumericButton ("0"); nextRow (); ... }
Jan 25 2004