Jump to content

How to toggle color of UniCanvas?


elGringo

Recommended Posts

Hi, all

doing like this

procedure TProductFrame.PaintUniCanvas;

begin




if UniCanvas.BitmapCanvas.Brush.Color=$A4A0A0 then
UniCanvas.BitmapCanvas.Brush.Color:=clWhite else
UniCanvas.BitmapCanvas.Brush.Color:=$A4A0A0;



UniCanvas.BitmapCanvas.FillRect(

Rect(

UniCanvas.Left+5,
UniCanvas.Top+5,
UniCanvas.Left+UniCanvas.Width-5,
UniCanvas.Top+UniCanvas.Height-5

)

);


IUniJSInterface(UniCanvas).JSCall('submitData', []);

end;

But changes only to one side to $A4A0A0 how to return to origin color?

Link to comment
Share on other sites

Hi,

 

Better that you will not use "submitData"

 

Otherwise you can try this:

procedure TProductFrame.PaintUniCanvas;
begin
  if UniCanvas.BitmapCanvas.Brush.Color=$A4A0A0 then
  UniCanvas.BitmapCanvas.Brush.Color:=clWhite else
  UniCanvas.BitmapCanvas.Brush.Color:=$A4A0A0;

  UniCanvas.BitmapCanvas.FillRect(
    Rect(
      UniCanvas.Left+5,
      UniCanvas.Top+5,
      UniCanvas.Left+UniCanvas.Width-5,
      UniCanvas.Top+UniCanvas.Height-5
    )
  );

  UniSession.AddJS('Ext.defer(function(){'+ UniCanvas.JSName +'.submitData()}, 20);');  //<<----------
  //IUniJSInterface(UniCanvas).JSCall('submitData', []);                                //<<----------

end;

Best regards.

Link to comment
Share on other sites

Thanks, decided problem with this 

procedure TProductFrame.TogglePaintUniCanvas;

var index:Integer;

begin


if FSelectedColor then

// Deselecting
begin
FSelectedColor:=false;
UniCanvas.BitmapCanvas.Brush.Color:=FOriginColor;


end else


 // Selecting
begin
FSelectedColor:=true;
UniCanvas.BitmapCanvas.Brush.Color:=$A4A0A0;



end;



UniCanvas.BitmapCanvas.FillRect(

Rect(

UniCanvas.Left+5,
UniCanvas.Top+5,
UniCanvas.Left+UniCanvas.Width-5,
UniCanvas.Top+UniCanvas.Height-5

)

);


//IUniJSInterface(UniCanvas).JSCall('submitData', []);

end;

Also what is initial color of TUniCanVas?

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...