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

Context menu does not close the first time when editing an item's text #14

Open
eclipse666 opened this issue Nov 23, 2021 · 2 comments
Open

Comments

@eclipse666
Copy link

To reproduce:
Run the full demo
click on an item to rename it so edit box appears
right click to display context menu (for copy/paste etc)
selecting a context menu item does not close the context menu - you have to select it again to close it.

Bug appears to be in TEasyEditManager.BeginEdit

I've used both Delphi 11 and Delphi 10.3 and had the same problem with both.
This problem does not occur with Delphi 2007 so it's something to do with changes in newer Delphis.

@eclipse666
Copy link
Author

I think I've found the problem.

Update TEasyBaseEditor.ControlWndHookProc as follows:

procedure TEasyBaseEditor.ControlWndHookProc(var Message: TMessage);
//
// Window procedure hook for the Edit box, allows autosizing of edit during user
// input
//
var
  Menu: TPopupMenu;
begin
  case Message.Msg of
  WM_EDITORRESIZE:
    begin
      ResizeEditor;
    end;
    WM_CHAR:
      begin
        if Message.WParam = VK_TAB then
          Message.WParam := Ord(' ');
      end;
    WM_CONTEXTMENU:
      begin

        Menu := nil;
        Listview.DoItemGetEditMenu(Self, Menu);
        if Assigned(Menu) then
          Menu.Popup(LOWORD(Message.LParam), HIWORD(Message.LParam))
        (*
        // comment out this part from here
        else
        begin
          // Don't let the VCL hook the parent window background menu to the editor
          CallWindowProc(TWinControlHack(Editor).DefWndProc, Editor.Handle, Message.Msg, Message.wParam, Message.lParam);
        end
        // to here
        *)
        ;
        Message.Result := 1;

      end;
  end;
  FOldWndProc(Message)
end;

@romankassebaum
Copy link
Contributor

I cannot believe that

      Menu.Popup(LOWORD(Message.LParam), HIWORD(Message.LParam))

does work under Win64. The original line

      Menu.Popup(Message.LParamLo, Message.LParamHi)

should be correct. I committed the rest.

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