Subject RE: [IBO] iboBars Shortcut
Author Michael L. Horne
Hello

It just happened that I was working on some code to setup
shortcuts for a form I was working on.

Some thoughts on design to start with:
1. Should it append or insert?
2. If in insert mode and at EOF file on scroll down should
it insert a new record.
3. If scrolling and in insert mode and no changes had been
made then should I cancel the insert? Or post an empty record?
4. Place the code in the FormKeyDown where it can be checked
for each component to see if the keys should be processed.
Or build into a component that hooks to a dataset and monitors
keyboard messages. Automatically processing the commands for
for that dataset if in a component that is attached to it
when the key is pressed?
5. Should what happens on key press match what exactly happens if
a button on the NavagationBar or the UpdateBar is pressed?
6. Should I create my own code or talk Jason into making/using
some modifications to the way the bars work.
7. How would I design a component that could determine on all
types of components what dataset they where attached to?
8. Should I just convert the code like this that I wrote for
TTable and be done with it.

What are your thoughts?

----------


My first thoughts where lets do the simple thing, something like:

procedure TformShipTo.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
// NOTE: 17 value of Key with only CTRL pressed
if (ssCtrl in Shift) and (Key <> 17) then
begin
case Key of
VK_UP: begin NavBarShipTo.BtnClick(nbPrior); key := 0; end;
VK_DOWN: begin NavBarShipTo.BtnClick(nbNext); key := 0; end;
VK_HOME: begin NavBarShipTo.BtnClick(nbFirst); key := 0; end;
VK_END: begin NavBarShipTo.BtnClick(nbLast); key := 0; end;
VK_DELETE:begin UpBarShipTo.BtnClick(ubDelete); key := 0; end;
VK_INSERT:begin UpBarShipTo.BtnClick(ubInsert); key := 0; end;
end;
end;
end;
end;

But I quickly found that if I tried to scroll beyond the displayed rows
I got exceptions like E_BEGINNING_OF_Dataset, so I added a little more code:

VK_UP: begin
if (NavBarShipTo.Buttons[nbPrior].Enabled) then
NavBarShipTo.BtnClick(nbPrior);
key := 0;
end;

This solved that problem but, also, needed to check to see if I was
in Insert mode, if so then when scrolling I needed to check to see
if the record had been modified if it had NOT then I didn't want to
post the empty record, I wanted it to cancel. If I was scrolling up
cancel/prior worked fine, if I was going down then just cancel. Of
course if the record had changed then I wanted to post and go to the
previous or next record.

As you can see this gets more and more complicated.

I am going to convert the code that I wrote for TTables to work with
IB_Datasets. It will handle the job, but I am not sure it is the
best result. I will post this section of code to the News Group
Tonight or Tomorrow.

I look forward to reading your thoughts on the problem.

Michael L. Horne