Canvas1.Graphics help please

Hello,

I am using help from https://forum.xojo.com/51035-graphics

I am trying to upgrade my project which works well in Xojo 2018 Release 2, I am now building it in Xojo 2018 Release 4 and am having some issues…

In Xojo 2018 Release 2 Canvas1.MouseDown I have the following code
app.gMousedownXD = X
app.gMousedownyD = Y

In Canvas1.MouseUp, I have
app.gMousedownXU = X
app.gMousedownYU = Y

Canvas1.Graphics.ForeColor = &cFF0000
Canvas1.Graphics.DrawOval ( app.gMousedownXD-3, app.gMousedownYD-3, app.gMousedownXU-app.gMousedownXD+6, app.gMousedownYU-app.gMousedownYD+6 )
Canvas1.Graphics.DrawOval ( app.gMousedownXD, app.gMousedownYD, app.gMousedownXU-app.gMousedownXD, app.gMousedownYU-app.gMousedownYD )

and that works well… the marquee is displayed.


in Xojo 2018 Release 4 Canvas1.MouseDown I have the following code
app.gMousedownXD = X
app.gMousedownyD = Y

In Canvas1.MouseUp, I have
app.gMousedownXU = X
app.gMousedownYU = Y

MouseUp = true // MouseUp is a property
Invalidate()

In Canvas1.Paint I have
if MouseUp = true Then
g.ForeColor = &cFF0000
g.DrawOval ( app.gMousedownXD-3, app.gMousedownYD-3, app.gMousedownXU-app.gMousedownXD+6, app.gMousedownYU-app.gMousedownYD+6 )
g.DrawOval ( app.gMousedownXD, app.gMousedownYD, app.gMousedownXU-app.gMousedownXD, app.gMousedownYU-app.gMousedownYD )

MouseUp = false

else
// Paint it in normal state
end if

When I do a Canvas1.MouseDown followed by a Canvas1.MouseUp at a different co-ordinate
I do not see any marquee but in Xojo 2018 Release 2 the marquee is displayed.

Any suggestions?

Thanks.

Lennox

Make sure you don’t have any controls on top of your canvas that are set to transparent as this will cause an additional paint of Canvas which will render at the MouseUp = False state.

Hi Julian,

I removed all controls from the window and it’s a canvas only in a window now… No marquee displayed.

Thanks.

Lennox

Did you return true from MouseDown?

Thanks Julian,

Working now.

Thanks again.

But If I wand a second marquee how do I do that?

Thanks.

Lennox

Yes I did Jim, and Julian’s advice worked, but now I want a second and more marquees.

Any advice?

Thanks.

Lennox

Sorry I didn’t respond to this, I must have got distracted by something shiny :wink:

I’d suggest drawing to a separate picture much like you would have done with your previous version. Then in the paint just draw the picture to the canvas. That will keep any state mechanics away from your paint routines, make your paint routines quicker and allow you to use refrechrect where you are drawing your ovals so you can target your paint to just update the portions of the image that change, again making everything quicker.

Here’s a simple version I put together for someone back in November.

https://www.dropbox.com/s/rduxbjwkgp3yzzn/PaintBuffer.xojo_binary_project?dl=1

Thanks Julian,

I will try it out.

Regards.

Lennox

https://blog.xojo.com/2018/12/06/updating-code-that-used-the-graphics-property/

Thanks Emile,

I tried that but I cannot get multiple ovals.

I can do multiple ovals when compiled in Xojo 2018 Release 2 but not Xojo 2018 Release 3 or Xojo 2018 Release 4.

Would you like to see the project?

Thanks.

Lennox

Yes please

The Paint Buffer project extended a bit
works fine under R4

https://www.dropbox.com/preview/PaintBuffer%20(10).xojo_binary_project?role=personal

sorry
https://www.dropbox.com/s/yqk6x1m7d3fbyfx/PaintBuffer%20(10).xojo_binary_project?dl=0

Do you have a link for the HalloMann image?

https://www.dropbox.com/s/flujft58k7djnde/Malmann.png?dl=0

You can take any picture

Hi Julian,

The project has been uploaded here… https://www.mediafire.com/file/4ngk8i7ha8aq2al/Multiple_Graphic_Marquee_2019_Feb_10'.xojo_binary_project/file

After compiling on Mac, launch the app, drop a .jpg or .png file, then do multiple marquees.

Thanks again.

Lennox

It was said here (and everywhere) that:

Canvas1.Graphics

no more working and was deprecated since Alley Oop was a teenager :wink:

So, create a Picture,
draw into it,
and in .Graphics, Draw that Picture (or in .backdrop).

In MouseUp: draw your small red circle in that Picture.

Edit:
BTW: your project works fine with 2015r1 :wink:

Did you read the two links at the bottom of:

https://forum.xojo.com/51639-old-funktion-graphics-in-xojo-2018r4

Hi Emile,

These two…
Xojo Blog: Updating Code That Used The Graphics Property
Xojo Documentation: Updating Code That Used the Graphics Property

I read them and I tried them, did not work, maybe I am still doing something wrong, any other advice?

Thanks.

Lennox