Jump to content

Block Diagram Key Focus


jgcode

Recommended Posts

[Cross-posted to NI]

Howdy!

Does anyone know of a scripting method to give focus to a free label decoration on the block diagram?

I just want to programmatically have the cursor appear at the end of some text in a free label.

We have the Key Focus property for a control, but is there something similar on the BD for text class object?

Cheers

-JG

Link to comment

I'm guessing this won't work, but you could try to type cast the reference to the text control class. If the BD text class has the relevant properties and they're just hidden, this may work, but it's more likely not to work at all (and it even has the potential to cause damage).

Link to comment

I'm guessing this won't work, but you could try to type cast the reference to the text control class. If the BD text class has the relevant properties and they're just hidden, this may work, but it's more likely not to work at all (and it even has the potential to cause damage).

Thanks Yair, the Text Reference is the same for the BD and FP, it was the control property I was after, so I don't know if it is possible :(

Link to comment

Propably you can workaround by creating a mouse click on the appropiat location. But this would be heavy coding if you need to interface that via Win API (and not nice plattform independent code).

Do we have some way to directly pass Mouse Events to LV?

Felix

Sounds hardcore for what I want to do :frusty:

I was actually refering to the string control class (although, as I suspected, the KeyFocus property is not supported). You can highlight the comment using the relevant method, but that won't edit it.

Hi Yair

That is what I meant when I said Control Class - but I get a type mismatch error when I tried to convert the Text Class to a String Class (which makes sense).

The problem is that I cannot get Text.Start-End Selection property to work either.

With Controls I need to put them in Focus first then use the Start-End Selection property otherwise that property doesn't work.

Am I doing this wrong for a BD label?

Cheers

-JG

Link to comment

I was playing around a bit as your question is related to mine. Maybe the following might get you a bit further, as I can't continue right now:

You can create a new String Control on the BD via scripting, but need to pass it as Decoration.Text (String Control from the Enum, Decoration.Text from the Type Specifier). Maybe this can be cast as String Control. If you set the Type Specifier to String Control, you get the error 'the BD is not able to hold that type'.

To go into more detail how the controls are constructed: The Key Focus is part of the 'Control' (or was it 'String Control' ?), while nested inside you get String Control.Text which is the same as Decoration.Text.

But I'm not sure how we can reach the container that contains the text and offers us the KeyFocus. I guess that owner is set by the New Object function.

Other ways to explore, but I still have no hint where to start: The method of GObject CallClassOp, but I didn't find any call parameters searching on LAVA and NI. Even more of a hack would be (maybe it returns a parameter for CallClassOp) to get the binary of the String Control and look for any human readable text. Either we can dereference the Reference of the control (with some MemCpy things), use a hex editor to search the LV memory or we find it in an binary file (I did have a look at mesa.dll with wordpad with no positive results).

Felix

Link to comment

Got some time, so here the results.

New VI object: style = string Control 1; vi obj class = String Constant (Decoration.Text does not work).

To type cast the object, instead of to more specific class, I use Flatten To/Unflatten From String (works without errors). Now I have the reference as String Control. If I try to set the Key Focus I get Error 1058 'Specified property not found'.

Felix

  • Like 1
Link to comment

Got some time, so here the results.

New VI object: style = string Control 1; vi obj class = String Constant (Decoration.Text does not work).

To type cast the object, instead of to more specific class, I use Flatten To/Unflatten From String (works without errors). Now I have the reference as String Control. If I try to set the Key Focus I get Error 1058 'Specified property not found'.

Felix

Haha! I was playing around with yours too but couldn't get anything to go yet :)

Thanks for working on this

Link to comment

...I get a type mismatch error when I tried to convert the Text Class to a String Class

You would, because they're not related. I put type cast in bold in my original post to indicate that you should use the type cast primitive, which doesn't do the type checking (similar to the flatten-unflatten trick Felix used), but just reinterpets the data on the wire. As I also said, it was a long shot which didn't pay off.

  • Like 1
Link to comment

You would, because they're not related. I put type cast in bold in my original post to indicate that you should use the type cast primitive, which doesn't do the type checking (similar to the flatten-unflatten trick Felix used), but just reinterpets the data on the wire. As I also said, it was a long shot which didn't pay off.

Ah - ok.

I have never down this before, so are you saying even if you get a type mismatch with the More Specific Class functions you could get access to other hidden private properties using type casting?

If so that is cool.

Link to comment

are you saying even if you get a type mismatch with the More Specific Class functions you could get access to other hidden private properties using type casting?

Yes, but the name and data type of the property have to match what you're wiring into it. I have no idea how many properties this applies to nor what will happen if the data type doesn't match. Once you type cast a reference, you're in uncharted waters.

I remember doing this specifically on BD comments which had some of the text properties, but didn't expose them.

Link to comment

In my case, I did replace the Flatten/Unfalatten by a simple Type cast and it works the same (less real estate used).

The main difference to your case is, that I travel down the class hierarchy (text is the inner part of string, ring is the inner part of all NamedNumeric's). But keyFocus seems to be as high as the general layer 'Control' in which the data container is embedded. From the errors I received, I guess that Diagram has not implemented whatever is necessary to pass the key focus to it's contents. Or does anybody have an example where you get some kind of Focus set on any BD-anything?

Felix

Link to comment

...text is the inner part of string, ring is the inner part of all NamedNumeric's

Actually, that's not true. I'm doing this from memory, but there are basically two String classes - one is the string control class (which inherits from the Control class) and one is the string constant class (which inherits from the Constant class). Both of them have a property which returns the reference to the text part of the string. The text itself is a class which inherits from the Decoration class, if I remember correctly.

As for the ring, the Ring class inherits from the Named Numeric class, but not all Named Numerics are rings (enums, for instance, are not. Not sure if there are others).

The VI server class hierarchy is quite easy to view in LabVIEW (and reasonably logical). Just open the class browser or drop a property node, right click and select Select Class.

But keyFocus seems to be as high as the general layer 'Control'...

That's correct. The KeyFocus property comes from the Control class, which is why I originally said it probably wouldn't work - because no one implemented it for the Constant class.

Link to comment

Here is what I am trying to do - posted on the Dark Side...

Hi Norm

All I am trying to do is create a shortcut for Size To Text property for a Free Label.

Just the same as when are typing into a String Constant and you can press Shift + Enter and it sets Size to Text = FALSE and jumps to a new line without adding a line feed constant (<LF>)

I thought Quick Drop (QD) would not disturb the flow of typing as currently I have to start and stop to do it.

Workflow:-

Typing text in Free Label reach certain width you do not want to exceed

Hit QD shortcut

Free Label text jumps to new line without adding a <LF>

Focus is returned to the new line

Continue typing etc..

Hope that makes sense.

Don't know if it's possible??

Link to comment

Yair: We should have a more complex view on the GObj hierarchy. The Inheritance tree is easy to browse as you descriped and also documented in the help (ther is a image of the tree structure of the public classes).

But some of the properties are references to other objects. Examples are Lable and 'Ring Text' (I wrongly refered to it as Ring, Ring Text is a Property of NamedNumeric, Hence also of Enum). These Objects are not creatable (we have Compositions, not Aggregations). These are also not part of the inheritance tree. We can identify these as they have a submenu in the property menu and have a reference there.

Others like Position (and I believe the 'Text' we are looking into) are of type Type Def'd Cluster (or in C-Terminology it would be a struct). They do not have a reference to return. I'm still a bit unsure if there are different properties called text or a struct might be shown inline in the Menu if no other properties exist (Like the Decoration.Text Class).

post-15343-126156312002_thumb.png

About the original problem, I fear that there is limited handling of User/Developer triggered Events/Actions (there are some Events for VI such as 'VI Activation'). But there are some helping properties to deal with it at the OS level, mainly I'm thinking about the BD.OSWindow property. There is a tool in the CR called 'Move Lable' which is using OS calls (Win) instead of scripting.

If we can write down, what exactly we would expect to get, we should get that on NI's Idea Exchange, so at least they are aware about it. Depending on how scripting is managed now (after the semi-offical release), we might get a solution just hacked in by someone inoffically (as the complete interface was done before).

Felix

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.