-
1 Attachment(s)
Test This Algorithm
Here is a test that moves between controls on ALT+ARROW_KEY. Mathematically, it moves correctly to the nearest control in a particular direction, however I think it intuitively feels wrong.
(i.e. it doesn't move where you think it should).
Anyone want to try and make it 'feel' better?
-
Would you compile it for me please? I'd try it, but my copy of VB is on a different computer...
(You'll prolly have to zip it once compiled so you can upload it.)
-
Not many people WANT an exe to test. :)
anyway, ya, don't feel right.
UP and DOWN are fine,
left and right are, first of all, reversed, and second of all,
just... wrong. like you said, you see what the reason is,
but we need a new reason. I don't know what that would
be aside from checking the alt+direction on each text box events.
-
-
1 Attachment(s)
I think it is because you are taking the left values of the text boxes and not considering the width, when moving right:
http://www.vbforums.com/attachment.p...postid=1184866
Text12 is obviously the closest to text11, but when just considering the top-left corner text13 is the nearest.
-
1 Attachment(s)
OK...
A new zip with exe for David (with L-R reversal fixed).
I think Martin is at least partly correct - I probably need to calculate distances from the centrepoint of each control.
I'm also wondering whether left and right should be more like a previous/next functionality (i.e. from top left to bottom right, cycling through the controls).
THis is all actually to get around a tab-ordering problem in a C++ GUI with a 'designable' interface. Another alternative would be some way to easily set the tab order of controls (a la Developer Studio). Currently we have to use Z-ordering and its a royal pain....
-
There's always the distance formula.
:p
-
Hi judd,
If, say, I choose left then I think the proggie should give more 'priority' to controls on the left, and possibly further away vertically.
So for instance, going left from Text6 should move to Text8 and not Text7.
Possible?
-
Hi David,
Good idea...looking at the code shows that I went for the simplest option to begin with - literally everything to the left is considered 'left'.
I could possibly calculate the proper direction vector from 0 - 360, but split the quadrant diagnally, like this:
Code:
\ | /
\ | /
\ U|P /
\ | /
\ | /
\ | /
\ | /
\ | /
\ | /
\ | /
\ | /
LEFT \|/ RIGHT
-------------------------
/|\
/ | \
/ | \
/ | \
/ | \
/ | \
/ | \
/ DO|WN \
/ | \
/ | \
/ | \
/ | \
Think that would be more logical?
-
Yes that would work better. Basically, you'resaying that you would give priority to moving to a more distant but more 'left' textbox than a closer but less 'left' one. Sounds good.
-
1 Attachment(s)
Update
This one 'feels' prety good. Distance is worked out center to center, and my quadrant is split diagonally.
PS...thanks to Guv for ArkTangent
-
Text12 goes to text1 and not text10, that just feels even more wrong than before, and text14 to text1 instead of text16.
-
Suggestions....?
You think its worse Martin?
Any suggestions? I can only think of using different rules for different areas.....but that gets v complex...
-
Some parts of it are better...some are worse though. I think you need to find the angle and the distance and somehow weight them. So the one with the most 'leftnest' (smallest angle) and the closest is the one picked. Give distance and angle different priorities. You'll work it out somehow...I may give it a go if I can be bothered...very busy atm though.
-
Just thinking...you could work out the absolute angle from the ideal and add it to the distance and the one with the smallest values wins...it might need some tweaking though.
-
-
Relating to this...
I want to randomly distribute the text boxes on my form (easy enough), but I don't want any of them to overlap?
Any built in VB way of checking this, or do I have to do it manually?