Recent

Recent Posts

Pages: [1] 2 3 ... 10
1
Rummy Modern has become increasingly popular as a variant of this classic card of the game in recent years. It is played with the same basic rules as traditional but may have additional features or variations depending on the specific version or platform. https://rummymodernapp.com/
2
Android / Re: [SOLVED] LAMW BackButton not working
« Last post by c4p on Today at 08:33:39 am »
Excellent.
3
Hello,
the file is downloaded in the download folder of the used webbrowser. Then you can move the file and rename it in another folder with the renameFile function. Example :
Code: Pascal  [Select][+][-]
  1. var
  2.   dat_old, dat_new: string;  
  3. begin
  4.   dat_old := 'C:\olddir\test.txt';
  5.   dat_new := 'C:\newdir\test.txt';
  6.  
  7.   if RenameFile(dat_old, dat_new) then begin
  8.     ShowMessage('Renaming was successful!');
  9.   end else begin
  10.     ShowMessage('Error!');
  11.   end;
  12. end;
Friendly, J.P
4
Other / Re: help choosing laptop
« Last post by dbannon on Today at 07:38:49 am »
Leledumbo, your existing Chromebook that you run Lazarus on, is it running Chrome OS still or have you installed Linux on it ?

Davo
5
Thank you Jamie. Here is all the code of the book https://github.com/MarcoDelphiBooks/ObjectPascalHandbook104
6
Linux / Re: any one knows how to set the environment in linux?
« Last post by greenzyzyzy on Today at 06:51:53 am »
No, I have never used SDL.

It sounds to me like you need to speak to the SDL people, not here.

The 'normal' model is you would build something like sdl in a dir inside you own space, using the source tree and running make from the right place. That way, the make file knows where everything it needs is. Once built correctly, you may then install it into places like /use/include. 

If the include files have got to /usr/include, then you must have already compiled (successfully) sdl and now want to compile your own app, dependent on the sdl libraries. ??

But, as I said, never built or used SDL.

Davo

yes, i feel it very hard.
7
How about this:

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, Controls, Forms, StdCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     Button2: TButton;
  17.     Button3: TButton;
  18.     CheckBox1: TCheckBox;
  19.     Edit1: TEdit;
  20.     Label1: TLabel;
  21.     procedure FormCreate(Sender: TObject);
  22.     procedure KeyPress(Sender: TObject; var Key: char); virtual;
  23.   end;
  24.  
  25. var
  26.   Form1: TForm1;
  27.  
  28. implementation
  29.  
  30. {$R *.lfm}
  31.  
  32. { TForm1 }
  33.  
  34. procedure TForm1.FormCreate(Sender: TObject);
  35. var
  36.   i: Integer;
  37. begin
  38.   for i := 0 to ComponentCount-1 do
  39.   begin
  40.     if not(Controls[i] is TWinControl) then Continue;
  41.     (Controls[i] as TWinControl).OnKeyPress := @KeyPress;
  42.   end;
  43. end;
  44.  
  45. procedure TForm1.KeyPress(Sender: TObject; var Key: char);
  46. var
  47.   S1, S2: string;
  48. begin
  49.   if not(Sender is TWinControl) then Exit;
  50.   S1 := (Sender as TWinControl).Name;
  51.   case Key of
  52.     #13: S2 := '[Enter]';
  53.     ' ': S2 := '[Space]';
  54.     else S2 := Key;
  55.   end;
  56.   Label1.Caption := S2 + ' is pressed on ' + S1;
  57. end;
  58.  
  59. end.
8
Code: Pascal  [Select][+][-]
  1. procedure TForm1.KeyPress(Sender: TObject; var Key: char);
  2. var
  3.   S: string;
  4. begin
  5.   if Sender = Button1 then
  6.     S := 'first button.'
  7.   else
  8.     if Sender = Button2 then
  9.       S := 'second button.'
  10.     else
  11.       if Sender = Button3 then
  12.         S := 'third button.'
  13.       else Exit;
  14.   Label1.Caption := Key + ' is pressed on the ' + S;
  15.  
  16.   DefocusControl(Sender as TWinControl, False); // Seems to work
  17. end;

I'm not sure if this is a good way of doing it, but it is working.
9
Maybe:

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, Forms, StdCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     Button2: TButton;
  17.     Button3: TButton;
  18.     Label1: TLabel;
  19.     procedure FormCreate(Sender: TObject);
  20.     procedure KeyPress(Sender: TObject; var Key: char); virtual;
  21.   end;
  22.  
  23. var
  24.   Form1: TForm1;
  25.  
  26. implementation
  27.  
  28. {$R *.lfm}
  29.  
  30. { TForm1 }
  31.  
  32. procedure TForm1.FormCreate(Sender: TObject);
  33. begin
  34.   Button1.OnKeyPress := @KeyPress;
  35.   Button2.OnKeyPress := @KeyPress;
  36.   Button3.OnKeyPress := @KeyPress;
  37. end;
  38.  
  39. procedure TForm1.KeyPress(Sender: TObject; var Key: char);
  40. var
  41.   S: string;
  42. begin
  43.   if Sender = Button1 then
  44.     S := 'first button.'
  45.   else
  46.     if Sender = Button2 then
  47.       S := 'second button.'
  48.     else
  49.       if Sender = Button3 then
  50.         S := 'third button.'
  51.       else Exit;
  52.   Label1.Caption := Key + ' is pressed on the ' + S;
  53. end;
  54.  
  55. end.

I'd rather not do it this way for two reasons: 1) I'd have to do this for every widget in the window which is more than the example in this post. 2) The keys are still be handled by the buttons. If the user hits enter, KeyPress does catch it but so does the button which means the button is clicked.

Edit: If you can prevent the second, this isn't so bad.
10
Focused or hovered? Controls have OnEnter and OnExit event handlers for focus changes. They also have OnMouseEnter and OnMouseLeave handlers for mouse hover.

All the above. I'd like to capture all keyboard input under all conditions. Even if a TEdit instance is entered/focused/active/etc.
Pages: [1] 2 3 ... 10

TinyPortal © 2005-2018