Confirm Inputquery with only one Enter

Asked

Viewed 105 times

1

I’m using a Inputquery to enable the user to have quick access to other parts of the system. The problem is that the process is to give agility and press twice the key Enter goes against the proposed objective.
Clarifying, when pressing once the key Enter, the focus goes to the OK button and pressing again the key Enter the button OK is pressed. What I want is to press the first time Enter, the pressure of the OK. I know it’s possible to create a new Inputquery to meet what I need.
But I wonder if it is possible and if so, how to do Inputquery standard provided by Delphi.

  if (InputQuery('Acessibilidade', 'Digite a tela', sTela)) and (Trim(sTela) <> '') then
  begin
    try
      sTela := Trim(StringReplace(sTela,'''','',[rfReplaceAll]));
      Query1.Close;
      Query1.SQL.Clear;
      Query1.SQL.Add('SELECT * FROM TELAS ');
      Query1.SQL.Add('WHERE TELA = '+Aspas(sTela));
      Query1.Open;
      if Query1.IsEmpty then
        Application.MessageBox('Tela inválida.','Atenção',MB_OK+MB_ICONINFORMATION)
      else
        Abre(Query1.FieldByName('tela').AsString);
    finally
      Query1.Close;
    end;
  end;
  • I tested here in Delphi 10, and in inputQuery, Enter already executes the OK button. ?

  • @Victortadashi I edited the question.

  • 1

    Your code worked perfectly here. Inputquery will open a screen, requesting the name of the program, this screen of Inputquery, has as default the OK button, IE, if you press Enter, it will trigger the action of this button. Unless your problem is on the screen I opened by Inputquery.

  • You killed the riddle! I remembered now that I have an application-level component that simulates the TAB by pressing the Enter. I hadn’t thought of that possibility.

  • Only one additional: when you press the Enter key and the OK button is automatically pressed it is caused by ModalResult, in the case of Imputquery the OK button is configured by default as Mrok.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.