Tokay Posted April 28, 2020 Share Posted April 28, 2020 I know how to popup a context menu: if Button = mbRight then UniPopupMenu1.Popup(X, Y, Sender); But how to do it with a Form? How to calculate relative X, Y params to absolute to set Left and Top of the popup Form? ClientToSreen doesn't works. But the Popup Menus can convert X and Y using the Sender. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 28, 2020 Share Posted April 28, 2020 2 hours ago, Tokay said: But how to do it with a Form? Hello, Sorry, can you please explain? Quote Link to comment Share on other sites More sharing options...
Tokay Posted April 28, 2020 Author Share Posted April 28, 2020 In the project exist the main form with TUniEdit on it. When I clicked on the TUniEdit I need to show another form in the place where I do click. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 28, 2020 Share Posted April 28, 2020 32 minutes ago, Tokay said: In the project exist the main form with TUniEdit on it. When I clcked on the TUniEdit I need to show another form in place where I do click. Maybe something like this? procedure TMainForm.UniEdit1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var _X, _Y: Integer; begin if Button = mbRight then begin _X := Self.Left + (Sender as TUniEdit).Left + X; // +/- _Y := Self.Top + (Sender as TUniEdit).Top + Y; // +/- with UniForm1 do begin WebForm.JSInterface.JSAddListener('beforeshow', 'function(){this.setPosition('+_X.ToString()+','+_Y.ToString()+')}'); ShowModal(); end; end; end; Quote Link to comment Share on other sites More sharing options...
Tokay Posted April 28, 2020 Author Share Posted April 28, 2020 Thank you for response. Second form shows, but position is wrong. Position is calculated from the form corner not the TUniEdit. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 28, 2020 Share Posted April 28, 2020 2 minutes ago, Tokay said: Thank you for response. Second form shows, but position is wrong. Position is calculated from the form corner not the TUniEdit. Can you make a simple testcase? Quote Link to comment Share on other sites More sharing options...
Tokay Posted April 28, 2020 Author Share Posted April 28, 2020 I understand what happens. Wrong position is obtained only when the TUniEdit is in the container, for example, in the TUniPanel. And this is my case - TUniEdit is the TUniDBGrid column filter. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 28, 2020 Share Posted April 28, 2020 Ok, I will check. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 29, 2020 Share Posted April 29, 2020 11 hours ago, Tokay said: I understand what happens. Wrong position is obtained only when the TUniEdit is in the container, for example, in the TUniPanel. And this is my case - TUniEdit is the TUniDBGrid column filter. Try to analyze and use the method that is used here. Quote Link to comment Share on other sites More sharing options...
Tokay Posted April 29, 2020 Author Share Posted April 29, 2020 Thank you very much! This approach works well. I added Quote function mousedown(sender, x, y, eOpts){ajaxRequest(sender, "_mousedown as event handler in the TUniEdit, and catch it OnAjaxEvent, and there I get needed coordinates. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 29, 2020 Share Posted April 29, 2020 Ok, very good Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.