Tabstops - IsDialogMessage_()

Everything else that doesn't fall into one of the other PB categories.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Tabstops - IsDialogMessage_()

Post by srod »

I guess this is aimed squarely at Fred/Freak, but, well, it has been raised (in various guises before) and so I am making a public posting.

This is something which has bugged me for a long time and has cropped up several times in discussions. In the past I have always dismissed this problem as not being particularly important, or at the least has not impacted my work at all... at least up to now. :)

It is to do with the way that PB handles the tab key in order to switch the focus between controls etc. PB would appear to set a keyboard accelerator for the tab key rather than process the IsDialogMessage_() function in its message loop. That is fair enough, until that is you turn to the Scintilla gadget!

Setting tabs within a Scintilla control has no effect (in that the tab key does not function) for a Scintilla control sitting within a window created by OpenWindow() etc. This is due in part because the Scintilla control does not swallow the tab key (perhaps because it does not process #WM_GETDLGCODE messages; I am unsure about this) and partly because PB sets the aforementioned keyboard accelerator.

Working around this requires removing the keyboard shortcut, which of course then stops us tabbing between controls! Catch 22.

You can see the problem with the following code which has removed the keyboard shortcut. Run without xp themes and click one of the buttons. Hitting the tab key will now not move the focus to the other button.

Code: Select all

If OpenWindow(0, 0, 0, 222, 200, "ButtonGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  RemoveKeyboardShortcut(0, #PB_Shortcut_Tab)

  ButtonGadget(0, 10, 10, 200, 20, "Standard Button")
  ButtonGadget(1, 10, 40, 200, 20, "Standard Button")

  Repeat
    eventID = WaitWindowEvent()
    Select eventID
    EndSelect
  Until eventID = #PB_Event_CloseWindow 
EndIf
Contrast this with the following in which I still remove the keyboard shortcut, but use IsDialogMessage_() within an api message retrieval loop (this time you can enable xp themes if you wish). You will need to use the debugger to kill this program.

Code: Select all

hWnd = OpenWindow(0, 0, 0, 222, 200, "ButtonGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If hWnd
  RemoveKeyboardShortcut(0, #PB_Shortcut_Tab)
  ButtonGadget(0, 10, 10, 200, 20, "Standard Button")
  ButtonGadget(1, 10, 40, 200, 20, "Standard Button")

  While GetMessage_(msg.MSG, #Null, 0, 0)
    If IsDialogMessage_(hWnd, msg) = 0
      TranslateMessage_(msg) 
      DispatchMessage_(msg) 
    EndIf    
  Wend 

EndIf
Not only does the second code function properly with regards the tab key, but even with xp themes enabled you can clearly see which control has the focus etc. Something which does not happen with the PB event loop!

Fred/Freak, is there any chance that IsDialogMessage_() can be added to the PB event loop in favour of adding the keyboard accelerator etc? As I say this has just been a minor inconvenience up to now for me, up to my working with the Scintilla control that is! The program I am working on needs to be completely cross-platform and so I am unable to dip into the api here. :)

Thanks.
I may look like a mule, but I'm not a complete ass.
freak
PureBasic Team
PureBasic Team
Posts: 5929
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Tabstops - IsDialogMessage_()

Post by freak »

srod wrote:Fred/Freak, is there any chance that IsDialogMessage_() can be added to the PB event loop in favour of adding the keyboard accelerator etc? As I say this has just been a minor inconvenience up to now for me, up to my working with the Scintilla control that is! The program I am working on needs to be completely cross-platform and so I am unable to dip into the api here. :)
We had a look at this after the recent discussions about the Tab/Arrow key behavior in PB windows. It is too late though to make this change in v4.40 as it needs some testing to make sure it doesn't break anything. We are planning to do this for the v4.50 then.

Btw, the way it is done in the IDE is to just remove the default Tab shortcut. Since there is not much else on the main window where you would want to move to with Tab, this is no problem.
quidquid Latine dictum sit altum videtur
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Tabstops - IsDialogMessage_()

Post by srod »

freak wrote:
srod wrote:Fred/Freak, is there any chance that IsDialogMessage_() can be added to the PB event loop in favour of adding the keyboard accelerator etc? As I say this has just been a minor inconvenience up to now for me, up to my working with the Scintilla control that is! The program I am working on needs to be completely cross-platform and so I am unable to dip into the api here. :)
We had a look at this after the recent discussions about the Tab/Arrow key behavior in PB windows. It is too late though to make this change in v4.40 as it needs some testing to make sure it doesn't break anything. We are planning to do this for the v4.50 then.
Ah, excellent. :)

What I have found in the past when using IsDialogMessage_() is that indeed some code was broken. I generally needed to process the #WM_GETDLGCODE message within certain subclassing procedures to fix the problems which I encountered (these were all with EsGRID when used with different programming langauges which had used IsDialogMessage_() within their message pumps).

For the moment I am simply removing the keyboard shortcut.

Thanks for the reply.
I may look like a mule, but I'm not a complete ass.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: Tabstops - IsDialogMessage_()

Post by rsts »

freak wrote:
srod wrote:Fred/Freak, is there any chance that IsDialogMessage_() can be added to the PB event loop in favour of adding the keyboard accelerator etc? As I say this has just been a minor inconvenience up to now for me, up to my working with the Scintilla control that is! The program I am working on needs to be completely cross-platform and so I am unable to dip into the api here. :)
We had a look at this after the recent discussions about the Tab/Arrow key behavior in PB windows. It is too late though to make this change in v4.40 as it needs some testing to make sure it doesn't break anything. We are planning to do this for the v4.50 then.

Btw, the way it is done in the IDE is to just remove the default Tab shortcut. Since there is not much else on the main window where you would want to move to with Tab, this is no problem.
Did this happen? How can I access the messages?

cheers
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Tabstops - IsDialogMessage_()

Post by Josh »

hi rsts,

no, it isn't done in 4.6

my first test was the following in the windowcallback, but i don't know, can i reset to the original tab-function with the third parameter in AddKeyboardShortcut:

Code: Select all

  If hWnd = hSci
    If uMsg = #WM_SETFOCUS
      RemoveKeyboardShortcut(nWnd, #PB_Shortcut_Tab)
      RemoveKeyboardShortcut(nWnd, #PB_Shortcut_Tab|#PB_Shortcut_Shift)
    EndIf
    If uMsg = #WM_KILLFOCUS
      AddKeyboardShortcut(nWnd, #PB_Shortcut_Tab, ???)
      AddKeyboardShortcut(nWnd, #PB_Shortcut_Tab|#PB_Shortcut_Shift, ???)
    EndIf
  EndIf
now i'm using the following workaround in the eventloop:

Code: Select all

  If Event = #WM_KEYDOWN
    If EventwParam() = #TAB
      If GetActiveGadget() = nSci
        SendMessage_(GadgetID(nSci), #WM_KEYDOWN, EventwParam(), EventlParam())
      EndIf
    EndIf
  EndIf
sorry for my bad english
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: Tabstops - IsDialogMessage_()

Post by rsts »

Thanks Josh.

Was hoping I had missed an announcement, but workarounds persist.

cheers
Post Reply