Jump to content

Object position (I have to pass name)


Arquem

Recommended Posts

 

Hello use unigui web application Framework 1.90.0 build 1505

I have this function that returns the position of the mouse click and positions the panel at the x and y coordinate. But I want to take a certain object that I will enter the name, then I want it to position next to it. Could you give me an example?

procedure TMainForm.UniPanel2Click(Sender: TObject);
var
  i: integer;
begin
  for i := 1 to 3 do
  begin
    pStatus := TUniPanel.Create(MainForm);
    with pStatus do
    begin
      Name := 'Option_' + inttostr(i);
      caption := name;
      Parent := sb;
      Top := i * 41;
      Height := 40;
      align := altop;
      color := RGB(Random(255), Random(255), Random(255));
      OnAjaxEvent := pAjaxEvent;
      ClientEvents.ExtEvents.Values['mousedown'] := 'function mousedown(sender, x, y, eOpts){ajaxRequest(sender, "_mousedown", ["x="+parseInt(x+sender.getX()), "y="+parseInt(y+sender.getY())])}';
    end;
  end;
end;

procedure TMainForm.pAjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
var
  p: TUniPanel;
  x,y: Integer;
begin
  if EventName = '_mousedown' then
  begin
    x := Params.Values['x'].ToInteger();
    y := Params.Values['y'].ToInteger();

    p := findcomponent((Sender as TComponent).Name) as TUniPanel;
    unilabel2.Caption := p.Caption;
    UniPanel3.Top := y;
    UniPanel3.Left := x;
  end;
end;

Link to comment
Share on other sites

18 hours ago, Arquem said:

I want to get the position of these components in yellow at runtime. Like a function that scrolls around and brings their position and names.

I don't know how to do this, can you help me please?

Sorry to clarify. 
It would be better to clarify where, when you want to get it and why?

Link to comment
Share on other sites

O problema sao os PARENTs... preciso pegar a POSICAO ABSOLUTA do componente... se um LABEL estiver DENTRO de um PANEL q ta dentro de outro etc... a posicao dele vai vir diferente da REAL. O componente é passado em tempo de execução.

Gostaria de saber exatamente a posição do UniPanel2 ao aparecer o mainform para fazer aparecer outro unipanel3 bem proximo dele, no unipanel3 vai ter um botão que ao clicar ira levar para bem proximo do outro componente por exemplo unibutton4 e assim por diante.

Vou mandar outra imagem para tentar explicar a ideia. 

Sem título1.png

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