April 25, 2024, 12:23:01 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Strange problem with accelerators

Started by aleksb, September 12, 2012, 08:38:06 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

aleksb

September 12, 2012, 08:38:06 AM Last Edit: September 12, 2012, 08:58:06 AM by aleksb
Hi,
I have a problem with the accelerator menu with some commands (Emergence Basic 1.737).
In my example I have a combo box that automatically closes when I click on, but other commands seem to be interfered with by the use of accelerators (such as scroll bars of a list box). Another anomaly that occurs is that the menu commands are executed twice, as you can see from the attached program. Removing the command ADDACCELERATOR everything works fine. This is a bug or my mistake?

$MAIN
AUTODEFINE "OFF"

DEF hmenu AS uint
DEF wmain AS window

OPENWINDOW wmain, 100, 100, 235, 100, 0x80CA0080|@HIDDEN, 0, "Problem...", &hmain
CONTROL wmain, @COMBOBOX, "Combo", 50, 4, 137, 200, 0x50A10603, 1
ENABLETABS wmain, 1

BEGINMENU wmain
MENUTITLE "File"
MENUITEM "Open\tF2", 0, 1
MENUITEM "Save", 0, 2
ENDMENU

ADDACCELERATOR wmain, @FVIRTKEY, 0x71, 1

ADDSTRING wmain, 1, "Text 1"
ADDSTRING wmain, 1, "Text 2"
ADDSTRING wmain, 1, "Text 3"

SHOWWINDOW wmain, @SWSHOW
WAITUNTIL wmain = 0

END

SUB hmain
 SELECT @MESSAGE
   CASE @IDMENUPICK
     SELECT @MENUNUM
       CASE 1
         DEBUGPRINT STR$(timer) + " Load"
       CASE 2
         DEBUGPRINT STR$(timer) + " Save"
     ENDSELECT
   CASE @IDCLOSEWINDOW
     CLOSEWINDOW wmain
   CASE @IDCONTROL
     SELECT @CONTROLID
       CASE 1
         DEBUGPRINT STR$(timer) + " Combo"
     ENDSELECT
 ENDSELECT
ENDSUB


***************
Edit:
In the meantime I tried to remove the command ENABLETABS (useless in this example) and it works.
It could be a conflict of accelerators with this function?

Thank you,
Alessandro.

AdrianFox

I had a problem with addaccelerator keys back in 2008 which resulted in the keypress producing three or four copies of each character for some reason.  When I disabled the accelerator key it disappeared.  (You can find my question about this if you do a search for Addaccelerator), but unfortunately Paul at the time could only say he had never come across it before.
If someone can explain what is happening in your case I will be interested to see what it is.
Adrian Fox

LarryMc

In the example above there are multiple problems
1. when the menu option are clicked it appears they have been clicked twice (as stated above)
2. the 3 string entries added to the combo have disappeared (not mentioned above)

removing the ENABLETABS command solves both problems and the combobox entries appear, the menu clicks fire single events and the F2 key works.

All the ENABLETABS command does is set an element in the WINDOWS UDT.
Tabbing for IWBasic windows is custom code.  Tabbing for dialogs is native OS code.
So, it appears there is a flaw in IWBasic's source code in how that element is used in the internal message handler that we can't see.

As mentioned, the tabbing feature isn't needed in the code posted above since there is only one control.  If there were more controls and tabbing was required than I would suggest using a dialog instead of a window as the parent.

Also mentioned above was a problem with scrollbars in a listbox.  I didn't try it but it is probably the Enabletabs also.

Maybe LarryS can put it on his list of things to look into.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library