Simple question lazarus / 8-Other ---------------------------------------------------------------------- Galbi · 2005-11-01 19:02 Hi friends, In a form whith multiple TEdits for entring data, how can I make the cursor go to the next TEdit, (after entering data in the first one), only striking [Enter], and nor having to strike [Tab] to move between the differents TEdits? Another: Can one procedure respond to two different events (i.e. on mouse click or pressing Enter)? How? Thanks from Argentina. Galbi. ---------------------------------------------------------------------- Jean-Marc · 2005-11-01 22:39 As you will always press "Enter" to finish typing in an edit, in the KeyUp event of your TEdit1, just type if Key= vk_Return then   Edit2.SetFocus; In the object inspector, you cannot call the same procedure directly for different kind of events, such as KeyPress and MouseUp, but you can still call the same procedure from both events if you want, inserting this call in the code of these events ---------------------------------------------------------------------- matthijs · 2005-11-02 15:45 A better solution might be: Code: [Select] procedure TForm1.Edit1KeyPress (Sender: TObject; var Key: Char); begin    If Key = #13 Then Begin      SelectNext(Sender as TWinControl,True,True);      Key := #0;    end; end; If you assign this method to the OnKeyPress-events of all your edits, you are done. ---------------------------------------------------------------------- Anonymous · 2005-11-02 23:15 First of all, Thanks for your answers... but I must confess that I feel a bit shy posting this type of questions so... Where can I learn how to do things like these? Actually what I'm doing is, reading some tutorials about Pascal, so later, read tutorials on Object Pascal and then (about year 2025 :-)) start doing something whith Lazarus. (As you can see, programimg is not my way of life, just a hobby. ) Do you think I'm on the right way? Thanks again. Galbi. ---------------------------------------------------------------------- matthijs · 2005-11-03 04:55 How to learn this? Well I a hobby programmer as well, I started with buying a Delphi book and joining a discussion group on CompuServe. (That was when Delphi 1 was released). But you could buy a Delphi book as well and start coding. A lot of things can be found on the internet as well. Google for enter as tab, among the results will be an "About Delphi" page giving you the code above. Having said that, about.com is also a very good point to start. And if you don't find your solution you can always ask here. ---------------------------------------------------------------------- Anonymous · 2005-11-04 23:33 Thanks Matthijs, my adventure whith Lazarus started when accidentally I started reading a book about Delphi 4 (from Victor Morral, Ed.Prentice Hall) but sometimes I found difficult to implement the examples of the book (my ignorance about Pascal may be the reason... I'm working on that). Your solution worked fine, (even I don't understand what it does, specially the line:               SelectNext(Sender as TWinControl,True,True); This morning I found in the Web a page with excersices and their solution so I have to study. Also thanks to Jean-Marc, I haven't tried your solution yet (hope tonight have some time to do it), I'll tell you later. Bye friends Galbi. ---------------------------------------------------------------------- matthijs · 2005-11-05 08:15 All components on a form have an taborder, that is a place in a list. SelectNext is a method of the form, which selects the next component in the list. Select has three parameters. The first one is the control which has currently focus. Then there are two booleans. The first one determines wether it should go forward or backward. True is forward, making the next component in the list receiving focus. The second one checks if the next component is a tabstop. This means will it receive focus when the user tabs around the form. The construction sender as twincontrol is necessary because the sender is an TObject but we know it is a TWinControl. The SelectNext method expect something of the type TWinControl. Therefor we have to cast the Sender. ---------------------------------------------------------------------- Anonymous · 2005-11-07 23:23 Thanks, you're a great help, and... if you don't mind... may I ask you another question? I'd like to read about what does the events of (let´s say TEdit) do? To this moment I've only used OnClick or OnEnter, but the others, are often used? The book I have it's not very clear on this topic, and haven't found something in the Web. Bye Galbi. ---------------------------------------------------------------------- matthijs · 2005-11-08 06:54 Did you have a look at this page? You could also have a look if you can get a Personal Delphi version somewhere. They were regulary distributed with magazines. Then you could have a look at the help files to see what all the events are doing, when they are triggered etc. Other events often used (at least by me ) are OnChange, OnKeyDown, OnKeyPress, OnKeyUp. Sometimes I use the OnMouseXXX-events for an edit. OnChange and OnExit can for example be used to check what the user has entered. The OnKeyXXX events can be used to make sure only valid characters are entered or as in the case above select the next component when the ENTER key is pressed. When I've got the time, I will try to write something about the different events. ---------------------------------------------------------------------- Anonymous · 2005-11-08 21:09 This page is excellent, thanks for the link, there it says that it's possible to download a free version of Delphi 6 (really, not at the moment, possibly in a few weeks) The question is, it's usefull to download that version or shall i continue learning whith Lazarus? See you. Galbi. ---------------------------------------------------------------------- matthijs · 2005-11-08 21:52 Stay with Lazarus. Lazarus is more complete then the Delphi personal version. Lazarus supports DB access where Delphi Personal does not. In due time Lazarus will be a tool you can use to devellop programs which can be used under windows, Linux or on a mac. I only advised to get a Delphi version to get at the help files. You can use these help-files to learn Lazarus. BTW. Another source of information is lazarus itself. It has al the sources available and when you study the sources you get a lot of information as well. ---------------------------------------------------------------------- alanphys · 2005-11-09 07:07 I found the above discussion very informative, but it has raised an ongoing problem again that I have with Lazarus running on linux. I use the OnExit event of a TEdit to check user input. If the input is invalid I prompt the user and use the SetFocus method of the TEdit to return the user to the Edit box.  This works correctly under Delphi, Kylix, Lazarus on Windows, but not Lazarus under Linux. I've not been able to find anything in the bug tracker or anywhere else. Is this just me or is it a problem? The following program illustrates: Place  two buttons and two edit boxes on a form and add the following events: {$mode objfpc}{$H+} interface uses   Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,   Buttons; type   TForm1 = class(TForm)      Button1: TButton;      Button2: TButton;      Edit1: TEdit;      Edit2: TEdit;      procedure Button1Click(Sender: TObject);      procedure Button2Click(Sender: TObject);      procedure Edit1Exit(Sender: TObject);      procedure Edit2Exit(Sender: TObject);   private     { private declarations }   public     { public declarations }   end; var   Form1: TForm1; implementation { TForm1 } procedure TForm1.Button1Click(Sender: TObject); begin Edit1.Setfocus; end; procedure TForm1.Button2Click(Sender: TObject); begin Edit2.Setfocus; end; procedure TForm1.Edit1Exit(Sender: TObject); begin Form1.ActiveControl := Edit1; Edit1.SetFocus; end; procedure TForm1.Edit2Exit(Sender: TObject); begin Form1.ActiveControl := Edit2; Edit2.SetFocus; end; initialization   {$I focusunit.lrs} end. Cheers Alanphys ---------------------------------------------------------------------- Anonymous · 2005-11-09 20:03 I need a compass... If I were to make a program whith a big database of products (aprox. 20.000) and every product should be searched via (at least) by one of three ways (bar code, official code or name), what kind of format this databese should have? Which it's the best (or easier)? Txt, dbf, pascal record, etc. Thanks. Galbi. ---------------------------------------------------------------------- matthijs · 2005-11-10 06:16 Quote from: "Anonymous"I need a compass... If I were to make a program whith a big database of products (aprox. 20.000) and every product should be searched via (at least) by one of three ways (bar code, official code or name), what kind of format this databese should have? Which it's the best (or easier)? Txt, dbf, pascal record, etc. Thanks. Galbi. Could you post this question in a new thread? That would make things more clearer to future readers. Topic switching is not a good thing to do. To give a short answer: Use a database like Firebird or MySQL. In another thread I could give some more directions. Note to moderators: Could you split these post to a new thread? Or if a new thread has been created remove this posts? ---------------------------------------------------------------------- matthijs · 2005-11-10 06:28 Quote from: "alanphys"I found the above discussion very informative, but it has raised an ongoing problem again that I have with Lazarus running on linux. This code would not work. Once EditBox1 or EditBox2 has focus you cannot remove the focus from this editbox.