c++builder How to prohibit dragging legends
-
- Newbie
- Posts: 27
- Joined: Wed Nov 09, 2022 12:00 am
c++builder How to prohibit dragging legends
How to prohibit dragging legends?
Re: c++builder How to prohibit dragging legends
Hello,
I don't understand what do you mean. The legend isn't draggable by default.
Could you please expand?
I don't understand what do you mean. The legend isn't draggable by default.
Could you please expand?
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 27
- Joined: Wed Nov 09, 2022 12:00 am
Re: c++builder How to prohibit dragging legends
Why is it possible to drag by default?
How to prevent the legend from being dragged?
How to prevent the legend from being dragged?
- Attachments
-
- 1122.png (11.86 KiB) Viewed 39808 times
Re: c++builder How to prohibit dragging legends
Hello,
Check the code and the form in your project.
If you still find problems with it, please arrange a simple example project we can run as-is to reproduce the problem here.
Thanks in advance.
Sorry but it should not be draggable by default.
Check the code and the form in your project.
If you still find problems with it, please arrange a simple example project we can run as-is to reproduce the problem here.
Thanks in advance.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 27
- Joined: Wed Nov 09, 2022 12:00 am
Re: c++builder How to prohibit dragging legends
I found the reason。
I added a selection tool to achieve drag and drop annotation functionality。
This causes the legend to also be dragged. How to solve this problem???
I added a selection tool to achieve drag and drop annotation functionality。
This causes the legend to also be dragged. How to solve this problem???
- Attachments
-
- 444.png (7.09 KiB) Viewed 39766 times
-
- 334455.png (13.83 KiB) Viewed 39766 times
-
- Newbie
- Posts: 27
- Joined: Wed Nov 09, 2022 12:00 am
Re: c++builder How to prohibit dragging legends
Does anyone answer my question???
Re: c++builder How to prohibit dragging legends
Hello,
Indeed, the
So, instead of having a
Indeed, the
TAnnotationTool
doesn't support dragging. However, the TRectangleTool
does.So, instead of having a
TAnnotationTool
and adding a TSelectorTool
to add dragging support to it, you could just use a TRectangleTool
.Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 27
- Joined: Wed Nov 09, 2022 12:00 am
Re: c++builder How to prohibit dragging legends
Due to requirements, I can only use Annotation. How can I prevent dragging legends?
Please provide a demo of c++builder。
Please provide a demo of c++builder。
Re: c++builder How to prohibit dragging legends
Hello,
You can't make the
You can't make the
TSelectorTool
not to detect the Legend. So, instead of using the TSelectorTool
, I'd implement the TAnnotationTool
dragging myself.Code: Select all
#include <VclTee.Chart.hpp>
#include <VclTee.Series.hpp>
#include <VclTee.TeeTools.hpp>
Code: Select all
private: // User declarations
TChart* Chart1;
TAnnotationTool* Annotation;
TPoint* annotationOffset;
bool annotationDragging;
void __fastcall ChartMouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y);
void __fastcall ChartMouseMove(TObject *Sender, TShiftState Shift,
int X, int Y);
void __fastcall ChartMouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y);
Code: Select all
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Chart1 = new TChart(this);
Chart1->Parent = this;
Chart1->Align = alClient;
Chart1->Color = clWhite;
Chart1->Gradient->Visible = False;
Chart1->Walls->Back->Color = clWhite;
Chart1->Walls->Back->Gradient->Visible = False;
Chart1->View3D = False;
for (int i=0; i < 2; i++) {
TFastLineSeries* fastLine = new TFastLineSeries(this);
Chart1->AddSeries(fastLine);
fastLine->FillSampleValues();
}
Annotation = new TAnnotationTool(this);
Chart1->Tools->Add(Annotation);
Annotation->Left = 100;
Annotation->Top = 100;
Annotation->Text = "Annotation tool";
Chart1->OnMouseDown = ChartMouseDown;
Chart1->OnMouseMove = ChartMouseMove;
Chart1->OnMouseUp = ChartMouseUp;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ChartMouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
if (Annotation->Clicked(X,Y))
{
annotationDragging = true;
annotationOffset = new TPoint(X-Annotation->Left,Y-Annotation->Top);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ChartMouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
{
if ((!annotationDragging) and (Annotation->Clicked(X,Y)))
{
Chart1->Cursor = crHandPoint;
Chart1->CancelMouse = true;
}
if (annotationDragging)
{
Annotation->Left = X-annotationOffset->X;
Annotation->Top = Y-annotationOffset->Y;
Chart1->CancelMouse = true;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ChartMouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
if (annotationDragging)
{
Chart1->Zoom->Active = false;
Chart1->CancelMouse = true;
}
annotationDragging = false;
}
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 27
- Joined: Wed Nov 09, 2022 12:00 am
Re: c++builder How to prohibit dragging legends
How to obtain a legend pointer for the Chart1MouseUp function???
Re: c++builder How to prohibit dragging legends
Hello,
You can access the Legend with
You can access the Legend with
Chart1->Legend
. Ie:Code: Select all
void __fastcall TForm1::ChartMouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
//...
Chart1->Legend->Color = clRed;
}
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 27
- Joined: Wed Nov 09, 2022 12:00 am
Re: c++builder How to prohibit dragging legends
How to determine whether the selected item is a legend in the Chart1MouseUp function???
Re: c++builder How to prohibit dragging legends
Hello,
You can check if the
You can check if the
Legend
is in a given position with the Clicked
function. Ie:Code: Select all
if (Chart1->Legend->Clicked(X, Y) > -1)
{
Chart1->Legend->Color = clRed;
}
else
{
Chart1->Legend->Color = clWhite;
}
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 27
- Joined: Wed Nov 09, 2022 12:00 am
Re: c++builder How to prohibit dragging legends
How to prevent the legend from being dragged during the chartmousemove event, as shown in the following example???
Re: c++builder How to prohibit dragging legends
Sorry, in what example?wrote: ↑Tue Aug 08, 2023 1:22 amHow to prevent the legend from being dragged during the chartmousemove event, as shown in the following example???
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |