Jump to content

TUniCanvas Background Color


dkeene

Recommended Posts

Howdy, hopefully simple question. I have TUniCanvas up and running, and am able to save pen strokes. They seem to be written on a black background. Is this able to be set to another color such as white? the pen stroke color  is easily changeable. Here's a screen snap of a scribble. Many Thanks.

 

snap081.png.19752eb4169cd7edbdba17be036f1bff.png

Link to comment
Share on other sites

  • 2 years later...
1 hour ago, Sherzod said:

but it doesn't work in my project, the background is always recorded as black in my project.

@ Şerzod

Hi,

I managed to create the problem, Attached you can see the test file.

The source of the problem is: The screen while drawing is normally green, but the background of the picture is black, the source of the problem is the Showmodal pop-up screen.

This problem occurs when I do FShowModal2.WindowState := wsMaximized How can i solve it.

Test.zip

Link to comment
Share on other sites

UniCanvas1.ClientEvents.ExtEvents ->

function afterrender(sender, eOpts)
{
    sender.getEl().on('resize', function(){
        ajaxRequest(sender, '_clear', {})
    });
}

UniCanvas1.OnAjaxEvent ->

procedure TFSerbestCizim.UniCanvas1AjaxEvent(Sender: TComponent;
  EventName: string; Params: TUniStrings);
begin
  if EventName = '_clear' then
  begin
    (Sender as TUniCanvas).Clear
  end;

end;

 

  • Thanks 1
Link to comment
Share on other sites

53 minutes ago, Sherzod said:

UniCanvas1.ClientEvents.ExtEvents ->

function afterrender(sender, eOpts)
{
    sender.getEl().on('resize', function(){
        ajaxRequest(sender, '_clear', {})
    });
}

UniCanvas1.OnAjaxEvent ->

procedure TFSerbestCizim.UniCanvas1AjaxEvent(Sender: TComponent;
  EventName: string; Params: TUniStrings);
begin
  if EventName = '_clear' then
  begin
    (Sender as TUniCanvas).Clear
  end;

end;

 

@Sherzod

Thanks for the solution, I've implemented it for now.

I think you will inform the team for permanent solution.
You're welcome, I'm grateful.

  • Upvote 1
Link to comment
Share on other sites

1 hour ago, Sherzod said:

UniCanvas1.ClientEvents.ExtEvents ->

function afterrender(sender, eOpts)
{
    sender.getEl().on('resize', function(){
        ajaxRequest(sender, '_clear', {})
    });
}

UniCanvas1.OnAjaxEvent ->

procedure TFSerbestCizim.UniCanvas1AjaxEvent(Sender: TComponent;
  EventName: string; Params: TUniStrings);
begin
  if EventName = '_clear' then
  begin
    (Sender as TUniCanvas).Clear
  end;

end;

 

@Sherzod

 

Changing the background color does not work when you add the codes you wrote, this problem occurs when you add your codes, I added an example.

image.thumb.png.a132f99c25b2722c13302ca36823e2e5.png

Test.zip

Link to comment
Share on other sites

8 hours ago, pro_imaj said:

Test.zip 31.41 kB · 1 download

procedure TFSerbestCizim.btnVazgecClick(Sender: TObject);
begin

  UniCanvas1.Color := clRed;
  UniCanvas1.Clear; //<--------

  //  FncUMGenel_ShowModal_Kapat(UniMainModule.ShowModalEkranNo,
  //    UniMainModule.SonucKod, UniMainModule.SonucAciklama);
end;

 

Link to comment
Share on other sites

5 hours ago, Sherzod said:
procedure TFSerbestCizim.btnVazgecClick(Sender: TObject);
begin

  UniCanvas1.Color := clRed;
  UniCanvas1.Clear; //<--------

  //  FncUMGenel_ShowModal_Kapat(UniMainModule.ShowModalEkranNo,
  //    UniMainModule.SonucKod, UniMainModule.SonucAciklama);
end;

 

@Sherzod

In your proposed solution; If the user wants to change the background color while drawing, you are clearing all their drawings, is there any way without clearing the drawings?

Link to comment
Share on other sites

1 hour ago, pro_imaj said:

In your proposed solution; If the user wants to change the background color while drawing, you are clearing all their drawings, is there any way without clearing the drawings?

Yes, this is impossible, in one canvas there is no concept of layering...

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...