A puzzle

Discussions related to mouse, keyboard, fonts and Graphical User Interface
KenDown
Posts: 327
Joined: Wed 04 Apr 2018, 06:36

A puzzle

Post by KenDown »

In my Display program I have four tabs, each one containing a dialog box. At the start of the program I have a *ESC OFF command. As you would expect, pressing ESC does not do anything.

One dialog box allows you to drag objects and position them on the screen. The dragging routine is a simple REPEAT:MOUSEx,y,b:drag to x,y:UNTLb=4 but if I happen to press ESC while that loop is in operation, the entire dialog box disappears. I have tried sticking ON ERROR LOCAL:VDU7 inside the loop but the beeb never sounds. If I have not entered the loop or after the loop is finished, pressing ESC does nothing. It's just during the loop that this happens.

I have, as a test, inserted IFINKEY-113=-1:VDU7 inside the loop and first the dialog box disappears and then the beep sounds.

Oh, and the loop does not stop. I can continue to position the object and return to other tabs and other dialog boxes, it's just this one box that disappears and doesn't return. I have to restart the program.

Any ideas, please?
Hated Moron

Re: A puzzle

Post by Hated Moron »

KenDown wrote: Wed 08 Jun 2022, 19:51 Any ideas, please?
Isn't this likely to be a simple 'focus' issue? When input focus is on the BBC BASIC window, the way ESC behaves is determined by BASIC (so it may be disabled by *ESC OFF). When the focus is on the dialogue box, BASIC no longer sees - or has any control over - keyboard input, so ESC behaves as it normally would in a dialogue box.

I don't think anything "puzzling" is happening.
KenDown
Posts: 327
Joined: Wed 04 Apr 2018, 06:36

Re: A puzzle

Post by KenDown »

Aaah. I don't think that particular gem is in the Help!

Thanks, though. I wonder if I can test at the end of the routine whether the dialog box is still open and if not, re-open it or reconstruct it.
KenDown
Posts: 327
Joined: Wed 04 Apr 2018, 06:36

Re: A puzzle

Post by KenDown »

In fact, double thanks! I have checked and you are quite correct. If the focus is in any of the dialog boxes and the user presses Esc, the dialog box disappears. Why anyone would do that, of course, is another question - accidents apart - for the only one where you might want to abandon the process is the second tab and dragging an object (and Esc doesn't in fact stop the process!)

So now at the end of the main loop I check if any of the dialog boxes have closed and re-display them. Brilliant.
Hated Moron

Re: A puzzle

Post by Hated Moron »

KenDown wrote: Thu 09 Jun 2022, 05:58 I don't think that particular gem is in the Help!
Well, the BBC BASIC Help manual doesn't purport to fully document the Windows GUI - not least because it would be impossible. Whenever you are dealing with native Windows controls (dialogue boxes, buttons, etc.) you inevitably have to turn to Microsoft for detailed information.

Dialogue boxes closing when ESC is pressed is absolutely standard in Windows. It's been discussed here before; one specific occasion I remember was when it was noticed that the behaviour varies depending on whether your dialogue box has a Cancel or Close button with the standard ID of 2 (IDCANCEL) or not. If it does, pressing ESC behaves exactly like clicking that button, effectively it's the keyboard shortcut for Cancel/Close. If however there is no such button, ESC still closes the dialogue box but returns a different code - possibly zero, I can't remember.

Arguably, an advantage of BBC BASIC for SDL 2.0 over BBC BASIC for Windows is that its GUI features - dialogue boxes etc. - are coded in pure, portable, BBC BASIC. Indeed it's so portable that the code will run in BB4W too! There are no cross-platform 'OS provided' GUI features that BBCSDL can use, so everything must be done in BASIC code. You can look at, and even customise, it.

Of course the selection of controls available in BBCSDL is limited compared with what Windows provides, but I'm always happy to receive code submissions for BBCSDL implementations of controls that aren't currently provided in the supplied libraries (or extending the capabilities of existing controls). One feature currently missing is word-wrap, so If somebody fancies modifying the editbox.bbc library that would be very welcome.
Hated Moron

Re: A puzzle

Post by Hated Moron »

Hated Moron wrote: Thu 09 Jun 2022, 08:39 the BBC BASIC Help manual doesn't purport to fully document the Windows GUI - not least because it would be impossible.
There is in fact a brief mention of the action of the ESCape key in dialogue boxes under Library Routines... Dialogue Boxes where it says "WINLIB2B also suppresses the automatic closing of the dialogue box when you click on its close button, or press Escape".
KenDown
Posts: 327
Joined: Wed 04 Apr 2018, 06:36

Re: A puzzle

Post by KenDown »

Wow! Now that is really useful. I have changed from WinLib2 to WinLib2U and the problem is solved. I just hope that some of the other things removed by that library do not prove to be important. At the moment everything seems to be working fine.

Thanks again.