Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] how to disable/disallow dragging column before/after certain column #936

Closed
Sorien opened this issue Nov 28, 2019 · 2 comments
Closed

Comments

@Sorien
Copy link
Contributor

Sorien commented Nov 28, 2019

I have own column with checkboxes and it has to be the first one all the time, but user can easily drag another one to the first position.

code below is working for me but I don't want to have such hacks in sources

procedure TVTHeader.DragTo(P: TPoint);

// Moves the drag image to a new position, which is determined from the passed point P and the previous
// mouse position.

var
  I,
  NewTarget: Integer;
  // optimized drag image move support
  ClientP: TPoint;
  Left,
  Right: Integer;
  NeedRepaint: Boolean; // True if the screen needs an update (changed drop target or drop side)

begin
  // Determine new drop target and which side of it is prefered.
  ClientP := Treeview.ScreenToClient(P);
  // Make coordinates relative to (0, 0) of the non-client area.
  Inc(ClientP.Y, FHeight);
  NewTarget := FColumns.ColumnFromPosition(ClientP);
  if NewTarget = 0 then // change
    Exit;                            //change

I see two possible options
#1 allow DragTo to be overridable.
#2 introduce new Column Option like TVTColumnOption.coNotDropable
#3 introduce some kind of event/function that can modify NewTarget

which would you prefer?

@joachimmarder
Copy link
Contributor

For now If prefer option 1, which I just committed.

introduce new Column Option like TVTColumnOption.coNotDropable

See this article. But I think that something like this could make sense and wondered if TColumnOption.coFixed should include the requested behavior. What sense could it make to allow dragging a non-Fixed column left of a Fixed column?

@Sorien
Copy link
Contributor Author

Sorien commented Nov 30, 2019

thx for changes, I understand that not all can be configurable ... to your question, I can't try it right now but I think that i saw some code that changes non fixed column to fixed when it's moved to left of fixed column (or between fixed columns) and vice versa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants