Re: Format

2021-05-21 Thread cc via Digitalmars-d-learn
On Saturday, 22 May 2021 at 03:14:35 UTC, cc wrote: Oops, disregard this. I had an error in my imports.😓 It does in fact work in @safe. I should add as an aside then that there is an issue of errors from the body of a toString template not being displayed, and instead the template being sile

Re: Format

2021-05-21 Thread cc via Digitalmars-d-learn
On Saturday, 22 May 2021 at 03:07:10 UTC, cc wrote: Ahh, in that case it would appear formattedWrite isn't @safe at all. Looks like you have to stick with put()? ```d @safe void toString(W)(ref W writer) if (isOutputRange!(W, char)) { //writer.formattedWrite!("FOO:%s", x); // fails

Re: Format

2021-05-21 Thread cc via Digitalmars-d-learn
On Friday, 21 May 2021 at 16:53:48 UTC, drug wrote: 21.05.2021 18:28, cc пишет: On Friday, 21 May 2021 at 14:19:03 UTC, newbie wrote: Thank you, and formatValue? formattedWrite should handle this. ```d @safe struct Foo { int x = 3; void toString(W)(ref W writer) if (isOutputRange!(

Re: Formatted output not on screen but in a string

2021-05-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 21 May 2021 at 22:37:34 UTC, Alain De Vos wrote: Next code format a string and prints it. But I want the formatted string stored in a string ``` //Decimal place separator %, writefln!"%,s"(123456789); //123,456,789 ``` std.format.format

Formatted output not on screen but in a string

2021-05-21 Thread Alain De Vos via Digitalmars-d-learn
Next code format a string and prints it. But I want the formatted string stored in a string ``` //Decimal place separator %, writefln!"%,s"(123456789); //123,456,789 ```

Re: gtkd , addondraw is deprecated

2021-05-21 Thread Mike Wey via Digitalmars-d-learn
On 21-05-2021 12:35, Alain De Vos wrote: What is the advised function to use instead of gtk.Widget.Widget.addOnDraw ? ``` this()     { addOnDraw(&drawCallback);} ``` Change the `Context` passed to the drawCallback to a `Scoped!Context` only the non scoped overload is deprecated. ``` bo

Re: Format

2021-05-21 Thread cc via Digitalmars-d-learn
On Friday, 21 May 2021 at 14:19:03 UTC, newbie wrote: Thank you, and formatValue? formattedWrite should handle this. ```d @safe struct Foo { int x = 3; void toString(W)(ref W writer) if (isOutputRange!(W, char)) { writer.formattedWrite("Foo(%s)", x); } }

Re: Format

2021-05-21 Thread newbie via Digitalmars-d-learn
On Friday, 21 May 2021 at 13:59:13 UTC, drug wrote: 21.05.2021 16:45, newbie пишет: I am following https://wiki.dlang.org/Defining_custom_print_format_specifiers, why sink and formatValue are not @safe? What are the best practice for toString in safe code? Thank you sink is obsolete now, use W

Re: Format

2021-05-21 Thread drug via Digitalmars-d-learn
21.05.2021 16:45, newbie пишет: I am following https://wiki.dlang.org/Defining_custom_print_format_specifiers, why sink and formatValue are not @safe? What are the best practice for toString in safe code? Thank you sink is obsolete now, use W(riter) ```D import std.range : isOutputRange; vo

Format

2021-05-21 Thread newbie via Digitalmars-d-learn
I am following https://wiki.dlang.org/Defining_custom_print_format_specifiers, why sink and formatValue are not @safe? What are the best practice for toString in safe code? Thank you

Re: gtkd ,drawingarea, capture mouse pressed

2021-05-21 Thread Alain De Vos via Digitalmars-d-learn
I found something, https://api.gtkd.org/gdk.Event.Event.getCoords.html

Re: gtkd ,drawingarea, capture mouse pressed

2021-05-21 Thread drug via Digitalmars-d-learn
21.05.2021 15:39, Alain De Vos пишет: I'll have a look at that website. With this code I capture the mouse press event ``` this() { addEvents(GdkEventMask.BUTTON_PRESS_MASK); addOnDraw(&drawCallback); addOnButtonPress(&onButtonPress); } ``` ``` public bool onButtonPress(Event event, Widget wid

Re: gtkd ,drawingarea, capture mouse pressed

2021-05-21 Thread Alain De Vos via Digitalmars-d-learn
I'll have a look at that website. With this code I capture the mouse press event ``` this() { addEvents(GdkEventMask.BUTTON_PRESS_MASK); addOnDraw(&drawCallback); addOnButtonPress(&onButtonPress); } ``` ``` public bool onButtonPress(Event event, Widget widget) { writeln("Button pressed"); retur

Re: gtkd ,drawingarea, capture mouse pressed

2021-05-21 Thread evilrat via Digitalmars-d-learn
On Friday, 21 May 2021 at 12:28:36 UTC, Alain De Vos wrote: On a gtkd drawingarea I want to capture the mouse-pressed event and get the coordinates of the pointer on the area. I have ``` addEvents(GdkEventMask.BUTTON_PRESS_MASK); ``` Maybe I must add a signal-handler ? Not a gtk user, but mayb

gtkd ,drawingarea, capture mouse pressed

2021-05-21 Thread Alain De Vos via Digitalmars-d-learn
On a gtkd drawingarea I want to capture the mouse-pressed event and get the coordinates of the pointer on the area. I have ``` addEvents(GdkEventMask.BUTTON_PRESS_MASK); ``` Maybe I must add a signal-handler ?

gtkd , addondraw is deprecated

2021-05-21 Thread Alain De Vos via Digitalmars-d-learn
What is the advised function to use instead of gtk.Widget.Widget.addOnDraw ? ``` this() { addOnDraw(&drawCallback);} ```