🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #9088

Re: Windows spacebar hotkey

#9088
From: Andrue Cope [TeamB]
Date: Fri, 30 Jul 2004 15:48
73 lines
4115 bytes
Chris Croughton wrote:

> Ah, I see.  So in this case it's the button which decides[1] that a
> space will mean "click" and a tab means "go to the next button" or
> whatever.  If the current focus is on an edit field, that interprets
> it.

Yes.

> Presumably the TEdit was the same size as the panel?

No - the size is irrelevant. The user won't be able to see the
component anyway. When the TEdit gets the focus I draw a border around
the TBitmap. It looks to the user like the TBitmap has just got the
focused but of course we know better (welcome to the inner circle of
programming <g>).

Hmmm:Golden rule of programming - the user only knows what you choose
to tell them. We have an application that can get blocked on file I/O.
In order not to look sluggish I tell the user that one particular
process has finished when in fact it's only half way through. We
actually designed the UI such that by the time user asks to view/use
the results they will be ready anyway. Thus the users think we have
some super duper highly efficient I/O code and we get to smirk a lot :)

But if the TEdit is not visible how can it get the focus? Answer;in two
ways:

1.Tab/Cursor keys.
It's enabled and flagged as visible so it's on the list. Press TAB
enough times and it'll get the focus. The fact the user can't see it
doesn't matter.

2.Someone clicks on the TBitmap.
How does that work? Simple:I give it the focus in the mouse down
handler for the TBitmap:

void __fastcall TfrmViewer::imgBlockViewMouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
  edtFakeFocus->SetFocus();

> The form responds to OnKeyPress?  How do you set it to do that?

Ah, a further note on focus. If the component that has the focus
doesn't respond to the message it gets sent on up to its parent
component. In my code the focus edit box has no OnKeyPress/OnKeyDown
handlers so the message is proprogated to its parent (a panel) and then
for the same reason onto the form.

> Yup, "getting it working" is what I need.

It can be a fine line. You don't want to write code without knowing why
it works but nor should you waste time (IMO) figuring out the best
possible solution. That's especially true in a RAD environment because
otherwise IMO what's the point in using RAD? RAD is largely about
getting the job done quickly. Win32 experts need not normally apply :)

> The superstition paradigm: it worked when I did it that way once, so
> I'll always do it that way <g>.

Yeah - do you know the story about the woman who chopped the end off
the meatloaf before cooking it because her mother always did it? When
/her/ daughter asked why it turned out it had nothing to do with
flavour - her own Mum just had a smaller oven at the time.

Again it's a balancing act. In this case I know it works. I know /why/
it works and I have 27MB of other source code to worry about. You have
to draw the line somewhere :)
-- 
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
Technical Details
Message-ID: <410a6de9@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4107b926$1@newsgroups.borland.com> <4107c851@newsgroups.borland.com> <slrncgg2ei.f6p.chris@ccserver.keris.net> <4108b254$1@newsgroups.borland.com> <slrncghsd7.7ug.chris@ccserver.keris.net> <4108fd87$1@newsgroups.borland.com> <slrncgkkn7.9lp.chris@ccserver.keris.net>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,af0a7a309a9df709
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Andrue Cope [TeamB]" <no.spam@spammy.com>
Subject: Re: Windows spacebar hotkey
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4107b926$1@newsgroups.borland.com> <4107c851@newsgroups.borland.com> <slrncgg2ei.f6p.chris@ccserver.keris.net> <4108b254$1@newsgroups.borland.com> <slrncghsd7.7ug.chris@ccserver.keris.net> <4108fd87$1@newsgroups.borland.com> <slrncgkkn7.9lp.chris@ccserver.keris.net>
User-Agent: XanaNews/1.16.3.1
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
NNTP-Posting-Host: 217.207.223.34
Message-ID: <410a6de9@newsgroups.borland.com>
Date: 30 Jul 2004 08:48:57 -0700
X-Trace: newsgroups.borland.com 1091202537 217.207.223.34 (30 Jul 2004 08:48:57 -0700)
Lines: 73
X-Authenticated-User: acope
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail