BBC BASIC for Windows
« Shortcuts »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:58pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Shortcuts  (Read 921 times)
JB91
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 47
question Shortcuts
« Thread started on: Jul 14th, 2010, 6:59pm »

How do you put in your program keyboard shortcuts like CTRL Z and CTRL O?
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
question Re: Shortcuts
« Reply #1 on: Jul 14th, 2010, 7:19pm »

on Jul 14th, 2010, 6:59pm, JB91 wrote:
How do you put in your program keyboard shortcuts like CTRL Z and CTRL O?

They can be read using GET, GET$, INKEY or INKEY$ just like any other characters from the keyboard. CTRL-Z is ASCII code 26 (SUB), CTRL+O is ASCII code 15 (SI). The full table of ASCII codes can be found in the main Help documentation here:

http://www.bbcbasic.co.uk/bbcwin/manual/bbcwinb.html#ascii

The supplied example program GUIDEMO.BBC responds to both menu selections and keyboard shortcuts .

Richard.
User IP Logged

JB91
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 47
question Re: Shortcuts
« Reply #2 on: Jul 15th, 2010, 3:13pm »

I tested it out and it seemed fine, but when I put it in my text editing program, it doesn't do anything. Any sugegstions?
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
question Re: Shortcuts
« Reply #3 on: Jul 15th, 2010, 5:18pm »

on Jul 15th, 2010, 3:13pm, JB91 wrote:
I tested it out and it seemed fine, but when I put it in my text editing program, it doesn't do anything. Any sugegstions?

The reason nothing happens is that the Windows Edit Control, which your program uses, takes the input focus away from your program. Therefore any input from the keyboard goes to the edit control rather than to your code.

There is no simple solution to this. The 'official' way would be to subclass the edit control and intercept the keyboard input, but this is an 'expert level' technique! You could try using the SUBCLASS library, which might at least allow you to write the code in BASIC, but failing that it would need assembler code.

You might be able to devise a satisfactory workaround by using INKEY with a negative parameter to test the keyboard directly, but it's quite difficult to guarantee that you would always see the shortcuts even if the keys were held pressed only for a short time.

So unfortunately I can't offer you a solution which is both straightforward and reliable! If it's any consolation (probably not) this is a tricky problem in any programming language, not just in BBC BASIC, because it's not something Microsoft seems to have made specific provision for.

Richard.
« Last Edit: Jul 15th, 2010, 5:20pm by admin » User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
question Re: Shortcuts
« Reply #4 on: Jul 16th, 2010, 10:38am »

on Jul 15th, 2010, 3:13pm, JB91 wrote:
Any suggestions?

OK, I found a workaround for your issue. The trick is to use a Keyboard Accelerator to convert the keyboard shortcuts to menu commands. The only awkward part is that to make this work you need to put the Edit Control in a dialogue box.

I have uploaded a modified version of TEXTEDIT.BBC here:

http://tech.groups.yahoo.com/group/bb4w/files/WindowsAPI/TEXTEDIT_accel.BBC

This implements keyboard shortcuts for New, Open, Save and Select All. Hopefully you will be able to adapt the technique to meet your requirements.

Richard.
User IP Logged

JB91
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 47
sad Re: Shortcuts
« Reply #5 on: Jul 16th, 2010, 3:24pm »

Am I supposed to just copy and paste it from the TEXTEDIT program? Because it doesn't work if you do it.

Josh.
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
question Re: Shortcuts
« Reply #6 on: Jul 16th, 2010, 7:24pm »

on Jul 16th, 2010, 3:24pm, JB91 wrote:
Am I supposed to just copy and paste it from the TEXTEDIT program? Because it doesn't work if you do it.

Obviously you may have to adapt it somewhat to the requirements of your program. I've given an example of how to do it, but it's up to you to work out exactly how to apply that example to your program. I can't write your code for you!

Richard.
User IP Logged

JB91
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 47
question Re: Shortcuts
« Reply #7 on: Jul 18th, 2010, 11:26am »

I did it, but whenever I typed, it comes up with:

"(C) Copyright R.T. Russell 2009"

Josh.
« Last Edit: Jul 19th, 2010, 3:14pm by JB91 » User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
question Re: Shortcuts
« Reply #8 on: Jul 18th, 2010, 4:41pm »

on Jul 18th, 2010, 11:26am, JB91 wrote:
I did it, but whenever I typed, it comes up with: "(C) Copyright R.T. Russel 2009"

Firstly, your copy of BBC BASIC for Windows is out of date. Only the current version is supported, which is 5.91b; update your copy (it's free) and see if that makes a difference.

Secondly, the name is Russell with two Ls, not Russel.

Thirdly, what you are seeing is the 'default' error message, i.e. what REPORT$ contains when no error has occurred. You need to debug your code to find out why. See here for hints on debugging:

http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin2.html#debugging

Richard.
User IP Logged

JB91
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 47
question Re: Shortcuts
« Reply #9 on: Jul 18th, 2010, 5:39pm »

Sorry! That was a mistake.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls