Recent

Author Topic: DBNavigator with shortcuts  (Read 7562 times)

Walmir

  • New Member
  • *
  • Posts: 39
DBNavigator with shortcuts
« on: July 10, 2014, 06:26:47 pm »
Hello,

is there a way to use shortcuts with DBNavigator?
For example, to use CTRL+S as a shortcut to the "Post" button of the DBNavigator.
I tried to use standard database actions, as TDataSetPost in an Action List, linked to menu items or buttons in a Toolbar, but they apparently are not ready to use...

Regards,
Walmir.

rvk

  • Hero Member
  • *****
  • Posts: 6948
Re: DBNavigator with shortcuts
« Reply #1 on: July 10, 2014, 07:09:41 pm »
As long as your form has focus there is no need to link the Actions of a TActionList to a button of Toolbar.
If you assigned shortcuts to the actions they are just there...
(Only if you want extra visible buttons, you'll link the action to those, but the shortcuts will work without them too)

You can just create a TActionList with Actions.
Assign the shortcuts to those Actions.
Write the events for those Actions (in the events you can do DataSet.Post, .Cancel etc)

If the shortcuts are not working, there could be a component blocking them (or catching the key).
Try setting a showmessage('hello'); in the event to see if it's triggered properly.
If it is, then you need to check how you're doing the DataSet.Post etc...

I tried to use standard database actions, as TDataSetPost in an Action List, linked to menu items or buttons in a Toolbar, but they apparently are not ready to use...
If you need help with the action-event you'll need to post some relevant code.

Walmir

  • New Member
  • *
  • Posts: 39
Re: DBNavigator with shortcuts
« Reply #2 on: July 11, 2014, 08:17:59 pm »
Hi,

In fact, the shortcuts in DBNavigator would be a solution to my problems with database standard actions.
I wrote no code. What I did:
1.  In a main form, put an ActionList
2. Added the standard database actions
3. Changed caption, name and shortcut of the database actions
4. Linked those actions to items on a submenu of the main menu and some toobuttons of a toolbar.
5. The data aware controls are in another form and the respective database componentes are in a data module.
6. When I run the application the menu items and the toobuttons are grayed, although the data are visible and editable in the secondary form.
This worked fine in Delphi... no need to code or even set the Database property of each database action.

PS: I really need the shortcuts because the application is meant to be used by people who have low vision or are blind.



rvk

  • Hero Member
  • *****
  • Posts: 6948
Re: DBNavigator with shortcuts
« Reply #3 on: July 12, 2014, 01:08:58 am »
2. Added the standard database actions
Wow, i had a hard time finding these. I've never used the standard actions.

4. Linked those actions to items on a submenu of the main menu and some toobuttons of a toolbar.
It's not strictly necessary to connect them to a toolbar or menu. The shortcuts should work anyway.
 
5. The data aware controls are in another form and the respective database componentes are in a data module.
It's a good thing you mentioned this.
If i have the database components on the same form as the data-aware controls the shortcuts work.
If i move them to a data module they stop working.
Yeah... this might be a bug.
Actually, like you mentioned in the other post, the shortcuts keep working, it's just the default Action (ExecuteTarget) which stops working.

(B.T.W. In the future please mention your OS, Lazarus and FPC version)
(aah, i see you already did in the other post but didn't in this one)

PS: I really need the shortcuts because the application is meant to be used by people who have low vision or are blind.

As a workaround you can place just one TDataSource on your form connected to the TDataModule.Dataset.
You don't need to do anything else (it doesn't need to connect to anything else).
It's really weird but after doing this the shortcuts (and ExecuteTarget) will work again.

You could also write an event for those actions with just these lines (all can be the same):
Code: [Select]
  with Sender as TDataSetAction do
    ExecuteTarget(DataSource);

I'm also still a newbie (so i don't know yet how to report a bug myself).
I saw taazz would look at this later this week.
« Last Edit: July 12, 2014, 02:11:19 am by rvk »

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: DBNavigator with shortcuts
« Reply #4 on: July 12, 2014, 09:17:33 am »
I'm also still a newbie (so i don't know yet how to report a bug myself).
Service announcement ;)
Go to bugtracker link for FPC or Lazarus project (depending on whether you are using Lazarus GUI controls or underlying FPC code; if you don't know, devs will change the bug report's project for you once you entered enough details)
Create an account if you haven't already, log in, create report, fill out details, including operating system and FPC/Lazarus version, bug description, preferably attach a zip file with example project that demonstrates the problem.

Background info
http://wiki.lazarus.freepascal.org/How_do_I_create_a_bug_report
and related pages
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

rvk

  • Hero Member
  • *****
  • Posts: 6948
Re: DBNavigator with shortcuts
« Reply #5 on: July 12, 2014, 09:56:46 am »
I'm also still a newbie (so i don't know yet how to report a bug myself).
Service announcement ;)
Ok, i was going to post a bugreport in bugtracker but, as per manual, while checking if the bug was already reported i found this:
http://bugs.freepascal.org/view.php?id=25441
(and maybe this http://bugs.freepascal.org/view.php?id=25988)

These report are still not assigned and/or closed/resolved.

I attached my test-project here.
(i haven't received my activation mail yet to do it there, i'll try to add my source there when i get access).

I used a TMemDataset for convenience (populating it in DataModuleCreate)
TMemDataset and TDatasource are in a Datamodule
TActionList with TDataSetNext and TDataSetPrior and TDBGrid are on a single form.
The TDBNavigator works as expected but the TSpeedButton's connected to the DatasetAction's are greyed out.
(They are connected to the TDatasource on the DataModule)

When i drop a single TDatasource on the form and connect it to TMemDataset they start working. (even though i didn't change the datasource on the DatasetActions.)

 

TinyPortal © 2005-2018