04-24-2024 02:08 AM
Hello everyone, I've encountered an issue with the 'Byte Offset from Point' method in LabVIEW. It seems to work fine when applied to a string directly, but when the string is within a cluster, the method doesn't function properly. Has anyone else experienced this issue, and if so, do you have any suggestions for resolving it? Thank you!
I have attached a simple code for demonstration.
Solved! Go to Solution.
04-24-2024 02:21 AM
My code as png:
04-24-2024 02:26 AM - edited 04-24-2024 02:28 AM
Hi Max,
I see the same behaviour in LV2019:
The byte offset is shown correctly for a string control on the front panel, but not when I move the string control into a cluster.
With string inside cluster I always get a result of "19" (aka string length)…
04-24-2024 03:55 AM
Thank you for your response.
Do you have any idea how to do it another way...?
04-24-2024 06:35 AM
I don't really have practical experience with this method, and the help for it doesn't specify what the coordinates actually are, but it looks like the coordinates are relative to the owning object (usually the pane, in this case the cluster). If you take the coords from the mouse event (which are in pane coords, I believe) and subtract the Position property of the owner, you can feed that into the method to get the correct offset.
Note that this is complicated by the existence of things like the label/caption/border/etc. which are included in the Position property. You can use the Master Bounds Rect property, but that's defined as a scripting method, so you would need to enable scripting to access it.
04-24-2024 07:55 AM
I have a Mouse Down Event configured on a string control that resides within a cluster. When the mouse is clicked within the string control, I need to determine the byte offset of the clicked position within the string.
To achieve this, I'm using the 'Byte Offset from Point' method in LabVIEW, passing the coordinates provided by the Mouse Down Event as the point argument. However, I've noticed that this method works perfectly when the string control is not within a cluster. But when the string is inside a cluster, the method fails to provide the correct byte offset.
Does anyone have any insights into why the 'Byte Offset from Point' method might behave differently when applied to a string within a cluster? Any suggestions or alternative approaches would be greatly appreciated.
Thank you for your help!"
04-24-2024 08:40 AM
I have a Mouse Down Event configured on a string control that resides within a cluster. When the mouse is clicked within the string control, I need to determine the byte offset of the clicked position within the string.
I have to do it without 'Byte Offset from Point' method.
that my code but I don't know what I'm missing... I think it's the initial position given to Get Text Rect.vi.
04-24-2024 08:59 AM
Hi Max,
@maxnoder1995 wrote:
that my code but I don't know what I'm missing... I think it's the initial position given to Get Text Rect.vi.
That is no code, it's an image of code.
We cannot edit/run/debug images with LabVIEW!
04-24-2024 09:31 AM - edited 04-24-2024 09:32 AM
@maxnoder1995 wrote:
I have a Mouse Down Event configured on a string control that resides within a cluster. When the mouse is clicked within the string control, I need to determine the byte offset of the clicked position within the string.
I have to do it without 'Byte Offset from Point' method.
that my code but I don't know what I'm missing... I think it's the initial position given to Get Text Rect.vi.
This small snippet should give an idea how to achieve this. Its not ideal, needs to be "fine tuned" for the clicks exactly between the chars (currently may give wrong answer), but I hope overall idea should be clear more or less.
04-24-2024 10:02 AM
Wow!! Thank you very much.
Use "Text.Positon" instead of "Position" to be precise.
If my text is justifed to the right, do you think it will be a problem to make it work?