Recent

Author Topic: Frame question  (Read 2323 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Frame question
« on: July 24, 2016, 11:02:19 am »
Hello guys, I have a question. I have a frame with a head edit. I wish that when I change the contents of the edit field of the frame would generate an event defined by me called CarriedEdit(myvalue: boolean) so that the parent can intercept the event. How can I do?

Obviously, the example I need to understand the operation, then I have to apply to more difficult things. Thank you
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Frame question
« Reply #1 on: July 24, 2016, 12:55:09 pm »
Create your frame in the normal way, add your edit, and then in the Object Inspector add an OnChange event to the TEdit.

The frame's parent can hook up to that OnChange event (which will be a published TNotifyEvent). It's not clear to me how you want to map an edit change to produce a boolean parameter, but obviously you can do whatever you want inside the method you link to the edit's OnChange.

Thaddy

  • Hero Member
  • *****
  • Posts: 14387
  • Sensorship about opinions does not belong here.
Re: Frame question
« Reply #2 on: July 24, 2016, 01:34:02 pm »
Well there should be a modified property (Tmemo has one for sure) which is a boolean...
Onchange fires every time yoe press a key. Most of the time it is better to check the modified property once.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Frame question
« Reply #3 on: July 24, 2016, 01:59:39 pm »
TEdit certainly has a Modified property which could be used. Note it is public (not published) so you can't pick it up using the designer, you can only access it in code.

Onchange fires every time yoe press a key. Most of the time it is better to check the modified property once.

How do you know at what moment to check modified? Every time OnChange fires, Modified is set to True. OnChange gives you the notification you need that a modification (change) has been made. Anyway, xlnylman will know what combination of property or event will suit his purpose.
« Last Edit: July 24, 2016, 02:09:29 pm by howardpc »

Thaddy

  • Hero Member
  • *****
  • Posts: 14387
  • Sensorship about opinions does not belong here.
Re: Frame question
« Reply #4 on: July 24, 2016, 06:04:41 pm »
TEdit certainly has a Modified property which could be used. Note it is public (not published) so you can't pick it up using the designer, you can only access it in code.


Ok I will answer that beginners question:
Code: Pascal  [Select][+][-]
  1. type
  2. TMyEdit = class (TEdit)
  3.  Published
  4.   property Modified;
  5. end;
  6.  

I guess you want to check modified on loosing focus? That would be efficient.

In a game scenario I might want to use OnKeyUp, though, but that is expensive....

Noob. No time for that. I have time for real questions like from OP.

Note that I see no real use for publishing modified...... You really want to use that in design mode? ... That's even more Noob...

Temperatures in my garden are still high. Icecubes are there, so no need to send them...
« Last Edit: July 24, 2016, 06:27:11 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

 

TinyPortal © 2005-2018