Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2003-09

how to implement TDBListBox.Readonly

6 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Andrew Johnson
to Marc Weustink: + From: Andrew Johnson + Sent: maandag 15 september 2003 3:34 + + I just decided to do…

Just to clarify here, we have a readonly property(all db aware controls do in delphi afaik), this sets the datalink readonly property to true or false. If its readonly then calling edit will validate false(I think) and apears to work in the DBEdit. now when the fieldlink is readonly we don't _want_ changes to happen same as when we aren't in editing(ala in browse) mode. Since a list set changes the field value to one in the list then we can't even let it change selection. So to make sure its properly readonly we need to prevent changing. I overrode click and keydown, but some messages still seem to be getting through. I tested this in Delphi4 and got what I expected - if I click something when readonly, nothing happens, in mine sometimes the selection changes... thats the issue.

I will try and implement keydown later too see if I can catch arrow, home page up/down and end there so they don't change selection.

(btw this is in cvs now if you want to look at what I mean)

Andrew

Michael Van Canneyt wrote 36 lines
On Mon, 15 Sep 2003, Marc Weustink wrote: > + From: Andrew Johnson > + Sent: maandag 15 september 2003 3:34 > + > + I just decided to do TDBListBox since I figured it should be another > + easy one, but I forgot about readonly. With Edti I could use inherited > + readonly to make sure it was uneditable, but with listbox there is no > + such thing. So I need to figure out how to handle this. I think I just > + need to add events for all mouse and keyboard events which would change > + the selection. So I wonder what all I need to be catching. obviously I > + need to do a KeyPress like I did with text, just add a test to make sure > + TFieldDataLink.Edit validates and if not set the Key to #0. However I am > + not sure what all else will need to be handled. aka what functions and > + within those functions what needs to be trapped. > + > + If anyone knows please tell me :) > + > + KeyPress won't get the arrow keys will it? > > Nope. KeyDown/Up will get all keys, KeyPress only those keys who return a > valid ASCII char. > > I just had a peek at the VCL and Readonly is handled through the DataLink. > If I understand what is happening, the ListBox isn't readonly. Only the > dataset isn't set to Edit when changing something in the listbox. The listbox should do that using TFieldDataLink.Edit, this will return true if the dataset is successfully set in editmode. Michael. _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email

Marc Weustink
to Andrew Johnson: I just decided to do TDBListBox since I figured it should be another easy one, but I…

+ From: Andrew Johnson
+ Sent: maandag 15 september 2003 3:34
+
+ I just decided to do TDBListBox since I figured it should be another
+ easy one, but I forgot about readonly. With Edti I could use inherited
+ readonly to make sure it was uneditable, but with listbox there is no
+ such thing. So I need to figure out how to handle this. I think I just
+ need to add events for all mouse and keyboard events which would change
+ the selection. So I wonder what all I need to be catching. obviously I
+ need to do a KeyPress like I did with text, just add a test to make sure
+ TFieldDataLink.Edit validates and if not set the Key to #0. However I am
+ not sure what all else will need to be handled. aka what functions and
+ within those functions what needs to be trapped. +
+ If anyone knows please tell me :)
+
+ KeyPress won't get the arrow keys will it?

Nope. KeyDown/Up will get all keys, KeyPress only those keys who return a valid ASCII char.

I just had a peek at the VCL and Readonly is handled through the DataLink. If I understand what is happening, the ListBox isn't readonly. Only the dataset isn't set to Edit when changing something in the listbox.

Marc

Reply by email

Andrew Johnson

I just decided to do TDBListBox since I figured it should be another easy one, but I forgot about readonly. With Edti I could use inherited readonly to make sure it was uneditable, but with listbox there is no such thing. So I need to figure out how to handle this. I think I just need to add events for all mouse and keyboard events which would change the selection. So I wonder what all I need to be catching. obviously I need to do a KeyPress like I did with text, just add a test to make sure TFieldDataLink.Edit validates and if not set the Key to #0. However I am not sure what all else will need to be handled. aka what functions and within those functions what needs to be trapped.

If anyone knows please tell me :)

KeyPress won't get the arrow keys will it?

Andrew

Reply by email

Michael Van Canneyt
to Marc Weustink: + From: Andrew Johnson + Sent: maandag 15 september 2003 3:34 + + I just decided to do…
Marc Weustink wrote 24 lines
+ From: Andrew Johnson + Sent: maandag 15 september 2003 3:34 + + I just decided to do TDBListBox since I figured it should be another + easy one, but I forgot about readonly. With Edti I could use inherited + readonly to make sure it was uneditable, but with listbox there is no + such thing. So I need to figure out how to handle this. I think I just + need to add events for all mouse and keyboard events which would change + the selection. So I wonder what all I need to be catching. obviously I + need to do a KeyPress like I did with text, just add a test to make sure + TFieldDataLink.Edit validates and if not set the Key to #0. However I am + not sure what all else will need to be handled. aka what functions and + within those functions what needs to be trapped. + + If anyone knows please tell me :) + + KeyPress won't get the arrow keys will it? Nope. KeyDown/Up will get all keys, KeyPress only those keys who return a valid ASCII char. I just had a peek at the VCL and Readonly is handled through the DataLink. If I understand what is happening, the ListBox isn't readonly. Only the dataset isn't set to Edit when changing something in the listbox.

The listbox should do that using TFieldDataLink.Edit, this will return true if the dataset is successfully set in editmode.

Michael.

Reply by email

Andrew Johnson

Hrmm. Ok, So I could let it change, and then just handle when it is changed and if readonly reset, to rematch the field? that would be easy enought to do for now.

And yes TDBRadioGroup would be a good one, its probably a bit more complicated then the ones I am doing(thus the reason I haven't looked yet), but very usefull to get going.

Andrew

Earlier message 29 lines
From: Mattias Gaertner Sent: Sep 15, 2003 11:26 AM To: Subject: Re: [lazarus] how to implement TDBListBox.Readonly On Mon, 15 Sep 2003 08:17:26 -0400 Andrew Johnson wrote: > Just to clarify here, we have a readonly property(all db aware controls > do in delphi afaik), this sets the datalink readonly property to true or > false. If its readonly then calling edit will validate false(I think) > and apears to work in the DBEdit. now when the fieldlink is readonly we > don't _want_ changes to happen same as when we aren't in editing(ala in > browse) mode. Since a list set changes the field value to one in the > list then we can't even let it change selection. So to make sure its > properly readonly we need to prevent changing. I overrode click and > keydown, but some messages still seem to be getting through. I tested > this in Delphi4 and got what I expected - if I click something when > readonly, nothing happens, in mine sometimes the selection changes... > thats the issue. > > I will try and implement keydown later too see if I can catch arrow, > home page up/down and end there so they don't change selection. I think, we should add the ReadOnly feature to TCustomListBox. And there are other ways than keys to change the selection. Maybe you should also implement a reset, when the selection changes. I will take one of the other TDBxxx controls. What about TDBRadioGroup?

Reply by email

Mattias Gaertner
to Marc Weustink: + From: Andrew Johnson + Sent: maandag 15 september 2003 3:34 + + I just decided to do…
Show quoted text 15 lines
Just to clarify here, we have a readonly property(all db aware controls do in delphi afaik), this sets the datalink readonly property to true or false. If its readonly then calling edit will validate false(I think) and apears to work in the DBEdit. now when the fieldlink is readonly we don't _want_ changes to happen same as when we aren't in editing(ala in browse) mode. Since a list set changes the field value to one in the list then we can't even let it change selection. So to make sure its properly readonly we need to prevent changing. I overrode click and keydown, but some messages still seem to be getting through. I tested this in Delphi4 and got what I expected - if I click something when readonly, nothing happens, in mine sometimes the selection changes... thats the issue. I will try and implement keydown later too see if I can catch arrow, home page up/down and end there so they don't change selection.

I think, we should add the ReadOnly feature to TCustomListBox. And there are other ways than keys to change the selection. Maybe you should also implement a reset, when the selection changes.

I will take one of the other TDBxxx controls. What about TDBRadioGroup?

Mattias

Show quoted text 48 lines
(btw this is in cvs now if you want to look at what I mean) Andrew On Mon, 2003-09-15 at 07:12, Michael Van Canneyt wrote: > On Mon, 15 Sep 2003, Marc Weustink wrote: > > > + From: Andrew Johnson > > + Sent: maandag 15 september 2003 3:34 > > + > > + I just decided to do TDBListBox since I figured it should be another > > + easy one, but I forgot about readonly. With Edti I could use > > inherited+ readonly to make sure it was uneditable, but with listbox > > there is no+ such thing. So I need to figure out how to handle this. I > > think I just+ need to add events for all mouse and keyboard events > > which would change+ the selection. So I wonder what all I need to be > > catching. obviously I+ need to do a KeyPress like I did with text, > > just add a test to make sure+ TFieldDataLink.Edit validates and if not > > set the Key to #0. However I am+ not sure what all else will need to > > be handled. aka what functions and+ within those functions what needs > > to be trapped.+ > > + If anyone knows please tell me :) > > + > > + KeyPress won't get the arrow keys will it? > > > > Nope. KeyDown/Up will get all keys, KeyPress only those keys who > > return a valid ASCII char. > > > > I just had a peek at the VCL and Readonly is handled through the > > DataLink. If I understand what is happening, the ListBox isn't > > readonly. Only the dataset isn't set to Edit when changing something > > in the listbox. > > The listbox should do that using TFieldDataLink.Edit, this will return > true if the dataset is successfully set in editmode. > > Michael. > > _________________________________________________________________ > To unsubscribe: mail with > "unsubscribe" as the Subject > archives at http://www.lazarus.freepascal.org/mailarchives _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email