Page 1 of 1

Tabstops - IsDialogMessage_()

Posted: Thu Nov 12, 2009 12:47 pm
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.

Re: Tabstops - IsDialogMessage_()

Posted: Thu Nov 12, 2009 3:42 pm
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.

Re: Tabstops - IsDialogMessage_()

Posted: Thu Nov 12, 2009 4:52 pm
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.

Re: Tabstops - IsDialogMessage_()

Posted: Fri Jun 01, 2012 11:59 am
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

Re: Tabstops - IsDialogMessage_()

Posted: Fri Jun 01, 2012 5:08 pm
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

Re: Tabstops - IsDialogMessage_()

Posted: Fri Jun 01, 2012 9:24 pm
by rsts
Thanks Josh.

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

cheers