I must admit to playing around with the tab order, because since the Window was created the Order No. Text Field (which is subclassed to allow numbers only) can never be tabbed into.
The Class Name Field is selected when the Window opens, I can type into it, hit the tab key and I am in the Class Number field, type into it, then I can tab until I am blue in the face, and I never get transferred to the Order No. Text Field.
At present, starting from the top of the tab order dialog box I have the Popup Control, the Class Name Text Field, the Class Number Text Field, and the Class Order Text Field, all the other controls are below these four.
What could possible be the cause of not being able to tab into the bottom Text Field?
Is TabStop turned off for that field? Click the gear icon to get to the advanced settings. TabIndex is editable there, as well. What do you get when you click the Show Tab Order icon?
Thanks for the quick reply. The following is what I have from the Show Tab Order icon in order from the top of the list, with right over to the right the tab order index from the gear icon:
I did notice that the OrderNumField was not in the right place (although its tab index was correct), I changed that before replying and that didn’t make any difference.
It looks like it should be working. I can’t reproduce the problem. Any rearrangement of the Show Tab Order list results in the right tab order. It really should be working for you.
Well, I guess I will just keep playing with it for a while. One thing I have noticed a couple of times with Xojo is that something may not be working quite how I expect it to (like this), so I sort of live with it. At the end of the day I quit out of Xojo and shut down my Mac. Then when I get back to it the next day, it is working as it should.
Whilst I was developing this window, even though it is really small, I played around with the controls and their names and position for quite a while. (I am sad to say that I am not into planning my apps, they sometimes just grow like topsy). I wonder if I manage to confuse Xojo (does it write temp files whilst in the debugger?) and then after a shutdown of both Xojo and the Mac, things get cleared out, and we start with a fresh slate?
Anyway, I have thought that I may rename this window (to keep the code), and create it again (in order) and see if that helps.
Thanks very much for taking the time to look at my post (and others that I have posted, I must add). This forum is really helpful and friendly compared with some I have been on. I am trying to post less and trying to work things out. But this really stumped me.
Asc(9) returned a Parameters are not compatible with this function error.
I cannot quite work out where to put the code. Of course in the keydown event I already have a Select Case for all the characters I want in the field, each Returning False; so I put it in the Else part. But I can’t use the name of the Field (OrderField.SetFocus) because it says OrderField does not Exist. If I put Me.SetFocus then it still doesn’t work.
I am sorry, but I still don’t understand where to put this code. In my subclassed TextField I don’t have a Keydown Event (obviously)
So in the actual class itself this is the code I have put:
Select Case Asc(Key)
Case 8
Return False
Case 13
Return False
Case 32
Return False
Case 48
Return False
Case 49
Return False
Case 50
Return False
Case 51
Return False
Case 52
Return False
Case 53
Return False
Case 54
Return False
Case 55
Return False
Case 56
Return False
Case 57
Return False
End Select
If Asc(Key) = 9 Then
Me.Setfocus
Return True
End If
I have put Me even though I know that applies both of the subclasses Text Field, but it still doesn’t work. Other than putting Me I don’t know how to refer to the TextField in question.
In your subclassed textfield you could create a Keydown event definition with the same signature as the standard keydown event, i.e.
Keydown(key as string) as boolean
Then in the select case you could add case else to the bottom before the end select and raise your custom event, i.e.
<snip>
Case 56
Return False
Case 57
Return False
Case else
Return RaiseEvent Keydown(key)
End Select
Then when you drag an instance of the class onto a window you can implement your Keydown event and you will receive the custom event when asc(Key) is not 8, 13, 32, etc. Then you will have to check if asc(key) = 9 from the window and you can set the focus to the correct textfield/control.
Hopefully this makes sense and doesn’t confuse you more
I must admit that had me a little excited for a second figuring out where to put what. But Xojo helped out by throwing up error messages all over the place, until I finally got it figured out. Now it works perfectly!!
I suppose it would be interesting to know why it didn’t work in the first place. I did try recreating the Window. Firstly I just put three TextFields on the Window, and I could tab to each of them. Then I added the other controls, and Still I could tab around OK. Finally I added the code, and suddenly once again I couldn’t tab to the third TextField. That really only leave one cause - there is something in my code that is causing this. However, although normally I try to be a perfectionist, in this case I am going to accept a workaround.
OK I will try that, maybe that is the sole cause of that TextField not being selected, because I am not allowing the tab key. As far as I know 8 is the backspace (delete) key. I want to allow people to correct any typing error they make without having to start over.
Tim, I put Case 9 into the Keydown Event and removed the Raised Event thingy that I did with help from Jason, and it worked. So that was the problem all along, the fact that I was blocking the tab key, because the Field just before the one in question was a NumbersOnly subclassed Text Field as well.
I am pleased that this is finally sorted out without any “fiddles” and Xojo is happy - so am I.
But I am also glad that I found out about the Raised Event procedure, as it may come in hand some time in the future.
Of course! I even have that in my own code, but forgot all about it. I was thinking 7, which is the bell, and wondering why you were testing for it. In that case, you might want to allow 28 and 29 (left/right arrow keys).