Subject | Re: [IBO] Behaviour of TIB_UpdateBar |
---|---|
Author | Salvatore Besso |
Post date | 2004-06-24T22:55:45Z |
ok Jason, this is the first question I asked a while ago:
change their state when pressed. That's to say that if I press the Edit
or the Insert button I go into edit or insert mode, ok, but the Edit or
Insert button remains enabled allowing to continue to click it (and
possibly generating errors if some sensible code is attached to the
OnBeforeAction or OnAfterAction events of the bar). I'm using IBO 4.3Aa.
Is this a normal behaviour? The other two visible buttons (Post and
Cancel) behave normally instead: Disabled when browsing, enabled in
edit mode. The bar is connected to one dataset only by mean of a
regular TIB_DataSource (the same used for the TIB_Grid).
[Added now:]
ReceiveFocus is False and AnnounceFocus of the datasource is False as well.
I don't use this feature here.
conclusion. Then I have made some debugging and I have found something
strange (almost to me) that I had reported always a while ago in the
thread. Here is the copy of that message:
IB_UpdateBar.pas starting at line 573:
Buttons[ ubEdit ].Enabled := ForceEdit or CanEdit;
Buttons[ ubInsert ].Enabled := ForceInsert or CanInsert;
Buttons[ ubDelete ].Enabled := ForceDelete or CanDelete;
Buttons[ ubPost ].Enabled := NeedToPost or ( State = dssSearch );
Buttons[ ubCancel ].Enabled := NeedToPost or ( State = dssSearch );
.....
Making some debugging I have noticed that when I arrive at the first
line of this fragment, ForceEdit is False and CanEdit is True, hence
the edit button is Enabled. But I cannot understand the logic of using
the dataset's CanEdit property to establish the state of the edit
button. If the dataset is editable, it is obvious that CanEdit is
always True and therefore the edit button will always be enabled,
whatever the state of the dataset is (unless there is something else
hidden deeply into IBO source, but I've not made too much source
mining :-).
And the same applies to CanInsert and CanDelete used for the other two
buttons. Doing so, these buttons will always stay enabled even if the
dataset changes its state and goes into insert or edit (or delete)
mode.
Instead NeedToPost (or state = dssSearch) seems more logic to me, because
the Post and Cancel buttons must be enabled if there is the need to post
(or cancel) something. And in fact the enable logic of these two buttons
seems correct.
If we really want Insert/Edit/Delete buttons always enabled, there are
other ways in TIB_UpdateBar object (snippet from source code):
{: This property is to make the Insert button always enabled even if
the dataset's CanInsert property returns false.}
property ForceInsert: boolean ...
{: This property is to make the Delete button always enabled even if
the dataset's CanDelete property returns false.}
property ForceDelete: boolean ...
{: This property is to make the Edit button always enabled even if the
dataset's CanEdit property returns false.}
property ForceEdit: boolean ...
Anyway it seems obvious, reading the above enabling code, that the
state of the three buttons doesn't really depend from the associate
dataset's state, but depends from something else.
Regards
Salvatore
> --------------------------------------------------------I have noticed that the TIB_UpdateBar's Insert and Edit buttons don't
change their state when pressed. That's to say that if I press the Edit
or the Insert button I go into edit or insert mode, ok, but the Edit or
Insert button remains enabled allowing to continue to click it (and
possibly generating errors if some sensible code is attached to the
OnBeforeAction or OnAfterAction events of the bar). I'm using IBO 4.3Aa.
Is this a normal behaviour? The other two visible buttons (Post and
Cancel) behave normally instead: Disabled when browsing, enabled in
edit mode. The bar is connected to one dataset only by mean of a
regular TIB_DataSource (the same used for the TIB_Grid).
[Added now:]
ReceiveFocus is False and AnnounceFocus of the datasource is False as well.
I don't use this feature here.
> --------------------------------------------------------then there were several replies from different users, but without a real
conclusion. Then I have made some debugging and I have found something
strange (almost to me) that I had reported always a while ago in the
thread. Here is the copy of that message:
> --------------------------------------------------------this is a fragment of method TIB_UpdateBar.SysStateChanged taken from
IB_UpdateBar.pas starting at line 573:
Buttons[ ubEdit ].Enabled := ForceEdit or CanEdit;
Buttons[ ubInsert ].Enabled := ForceInsert or CanInsert;
Buttons[ ubDelete ].Enabled := ForceDelete or CanDelete;
Buttons[ ubPost ].Enabled := NeedToPost or ( State = dssSearch );
Buttons[ ubCancel ].Enabled := NeedToPost or ( State = dssSearch );
.....
Making some debugging I have noticed that when I arrive at the first
line of this fragment, ForceEdit is False and CanEdit is True, hence
the edit button is Enabled. But I cannot understand the logic of using
the dataset's CanEdit property to establish the state of the edit
button. If the dataset is editable, it is obvious that CanEdit is
always True and therefore the edit button will always be enabled,
whatever the state of the dataset is (unless there is something else
hidden deeply into IBO source, but I've not made too much source
mining :-).
And the same applies to CanInsert and CanDelete used for the other two
buttons. Doing so, these buttons will always stay enabled even if the
dataset changes its state and goes into insert or edit (or delete)
mode.
Instead NeedToPost (or state = dssSearch) seems more logic to me, because
the Post and Cancel buttons must be enabled if there is the need to post
(or cancel) something. And in fact the enable logic of these two buttons
seems correct.
If we really want Insert/Edit/Delete buttons always enabled, there are
other ways in TIB_UpdateBar object (snippet from source code):
{: This property is to make the Insert button always enabled even if
the dataset's CanInsert property returns false.}
property ForceInsert: boolean ...
{: This property is to make the Delete button always enabled even if
the dataset's CanDelete property returns false.}
property ForceDelete: boolean ...
{: This property is to make the Edit button always enabled even if the
dataset's CanEdit property returns false.}
property ForceEdit: boolean ...
Anyway it seems obvious, reading the above enabling code, that the
state of the three buttons doesn't really depend from the associate
dataset's state, but depends from something else.
> --------------------------------------------------------Well, Jason, that's all. The ball is in your field now :-)
Regards
Salvatore