Listbox does not accept all keys

I think if you try… you might have to hold multiple keys, but it will only count as one keydown

the keydown event doesn’t “look back” as far as I know

Sorry, Alberto, deleted it at the same time you posted as I noticed my mistake.

[quote=412061:@Dave S]I think if you try… you might have to hold multiple keys, but it will only count as one keydown

the keydown event doesn’t “look back” as far as I know[/quote]

I remember on Windows doing ALT+164 and then a ñ appeared. Then I found out about other keyboards and “dead keys”. Now on my mac I use an international keyboard version (same layout as US keyboard) but with some dead keys, like ~, ', ", this let me write ñ, á and ü. I see Emile use Option-n for the same as ~, so in both cases a key (or combination of keys) are pressed to display the dead key first, then another key is pressed to complete the special character.

This result in 2 keydown, 1 for the dead key and 1 for the other key. After that both will count as 1 character and not 2.

I don’t know if there is something like ALT+164 on mac, and if that will fire keydown 3 times.

On Windows, if I press ALT-164, I only get one KeyDown event. It occurs after I release the Alt key, and the Len of the Key is 1. Are you guys getting different results?

Hi Tim, haven’t tested on Windows. I will test dead key ~ and n, I guess that will result in 2 KeyDown events.

I can’t find something like ALT-164 for mac, only information is Option-n, release, then n again, that’s why I get 2 KeyDown events.

Right, but I wouldn’t expect the dead key to be added to the Text value, just the final character, after the second KeyDown.

Interesting, my Windows 7 laptop has an extended keyboard (numbers on the right too).

I put a counter on KeyDown:

  • dead key ’ and a () = 1 KeyDown
  • dead key ~ and n () = 1 KeyDown
  • ALT and 164 with Num Lock on = 1 KeyDown
  • ALT and 164 with Num Lock off = 4 KeyDown

It makes sense that the dead key then regular key = 1 KeyDown because nothing is shown on screen until the character is finished. On mac you can see the dead key on screen with a yellow background, I think that’s why on mac we get 2 KeyDown events.

I wasn’t expecting 4 KeyDown events with Num Lock off.

With Num Lock off, the keypad keys are treated as arrow keys, home/end, etc.

That’s why is so weird, I didn’t expect to get after ALT-164 with Num Lock off. I get first KeyDown with pressing 1, second with 6, third with 4 and fourth when I release ALT and the appear on the TextField.

That’s a bug in the OS, then.

Much easier: just set LimitText to 40 … :wink:

In a current project, the main window have Listbox and TextField.

I set a KeyDown event into the TextField and set Listbox1.AddRow Str(Asc(Key)).

Run and you will know how many events happens.

DeadKeys:
Option-´ (áéíóú)
Option-` (àèìòù)
Option-¨(äëïöüÿ)
Option-^ (âêîôû)
Option-~ (ÃÑÕ, ãñõ)

Same for UpperCases. other option combinations exists (©?Ê, œŒ, etc.). Option-$ for €, Option-Shift-* for ¥.

This also exists on Windows…

Now, you (everybody) are free to think what you want.

Hi everybody

Wow -> what a support!!! Sorry, that I started such a confusion …

To clarify: As Alberto have assumed the problem was that no special characters (German Umlaute like ,) can be entered with that ActiveCell.Mask = “&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&” and need to limit to 40 characters.

-> I have deleted the ActiveCell.Mask now and make the following check in the Cellkeydown-Event from the Listbox:

            if len (me.activeCell.text) >39 and key <> chr(8) and key <> chr(9) and key <> chr(13) and key <> chr(3) then
              Beep
              return true
            end if

But now: I filtered the ascii Code from the Key pressed and got on my iMac with Swiss Keyboard connected the following codes:
-> Ascii Code 228
-> Ascii Code 252
-> Ascii Code 246
if I press first “” and 2nd “a” then I get 2 keydown Events. The Character displayed first are 2Dots with yellow background and after the second key pressed the character “” with Ascii Code 228.

With my LEN Check above I run know into problems when I entered 39 Characters and would like to enter a German Umlaut as Character No. 40. Pressing a “” on my keyboard works and the key is accepted. Entering the Umlaut with first “” and 2nd “a” does not work. Len is counting the 2 Dots and the “a” as two characters before the character is combined to “”. -> Sorry guys; complicated to explain.

Hi Claude,

the things follows that way since Macintosh XL (Lisa ?)…

My only unknow part was how things behaved under Xojo. Once tested, I can say your description is correct.

You are right. Sometings are not easy to explain to new comers. This is common knowledge in the old people (people who use a Macintosh from the down of times, 1982/1983/1984).

Cheers.

Edit: z.

[quote=412132:@Claude Senn]With my LEN Check above I run know into problems when I entered 39 Characters and would like to enter a German Umlaut as Character No. 40. Pressing a “ä” on my keyboard works and the key is accepted. Entering the Umlaut with first “¨” and 2nd “a” does not work. Len is counting the 2 Dots and the “a” as two characters before the character is combined to “ä”. → Sorry guys; complicated to explain.
[/quote]
Can you try what Markus said?

Ignore me. I‘m sick and obviously not thinking straight as that is for TextFields, not ListBoxes … though with setting the ColumnType to TextField (or checking for the right column) and a bit of casting it could maybe work …

[i]For example,

ListBox1.CellType(1,0) = ListBox.TypeEditableTextField
To get this TextField, you must put the cell into the Inline Editable mode via the CellType or ColumnType properties and make it editable by calling the EditCell method. You can use this property to set or get the text of the ListBox cell (using SelText), set the selection, or change other properties of the ListBox’s TextField.[/i]

So

lb1.ColumnType(1) = ListBox.TypeEditableTextField

And then something like

TextField( lb1.ActiveCell ).LimitText = 40

Haven‘t tried it. Back to bed.

Yes, this works (couldn’t resist trying despite much coughing):

[code]Sub Open() Handles Open
Me.ColumnType(1) = Listbox.TypeEditableTextField

For i As Integer = 0 To 10
Me.AddRow
Next
End Sub[/code]

Sub CellGotFocus(row as Integer, column as Integer) Handles CellGotFocus If column = 1 Then TextField( Me.ActiveCell ).LimitText = 40 End If End Sub

No problem with :wink:

Hei Markus

Thank you very much!! This works much better then the LEN-Function!!

Thank you for your help!!!

Glad to help. Please don’t forget to mark it as answer then so others looking for a solution see it together with your original question right at the top.