Is it possible to add an element to an array by pressing a button?
In such a way that the first press enters a '1' element, the second a '2' and so on.
Given how LabVIEW works, your question is borderline nonsensical. I'm going to try to untangle a few concepts that you seem to have conflated. I hope this doesn't come off as insulting -- I see genuine confusion and I'm hoping I can help.
First of all, what do you mean by "an array"? Do you mean the value on a wire or the value you see in a control on the front panel? LabVIEW's front panels are just the display of values computed in the block diagrams. In a running program, you never directly manipulate the values in any control. You can read the value, manipulate it, and then write it back to the control.
So, on the block diagram, yes, you can add an element to an array by using the "Build Array" node. And then you could display that value in an array indicator on the front panel.
You can have a button on the front panel that triggers an event. If that event code adds to an array, then you display that value in an indicator, then, yes, you can have a button that adds an element to an array. The code would look something like the code below. Notice that I never "add" an element to the array indicator. The array indicator simply updates every time the loop runs with whatever the computed value happens to be.
PS: the other frame of the event structure is just a "Stop" button handler.
The solution suggested by srm works fine.
Just a note: be careful with the tunnel options for the wires. If you add some other event cases on the Event Structure, you should disable the tunnel option: Use Default value. Otherwise, when this new event cases are handled, this reset the shift register array value.
See screeshot below
Related
When using NVDA on Firefox, it reads in row-wise order in React. How can I change the reading order?
Sample code:
<Row1>
<row-item-left>{some content1-left}</row-item-left>
<row-item-right>{some content1-right}</row-item-right>
<Row1>
<Row2>
<row-item-left>{some content2-left}</row-item-left>
<row-item-right>{some content2-right}</row-item-right>
<Row2>
Now it reads, "some content1-left, some content1-right, some content2-left, and some content2-right." I want it to read, "some content1-left, some content2-left, some content1-right," and, "some content2-right."
I use tabindex. It's working fine with tabs, but I don't want to focus elements Also it's not working with arrow keys. Please help me on this.
The reading order is always the same as it appears in the accessibility tree, and the accessibility tree is built from the DOM.
This basic rule can't be changed. CSS has no effect on reading order.
So if you want the content to be read column by column instead of row by row, you have no choice but rearrange your code so that it appears in the right order in the source:
<row-item-left>{some content1-left}</row-item-left>
<row-item-left>{some content2-left}</row-item-left>
<row-item-right>{some content1-right}</row-item-right>
<row-item-right>{some content2-right}</row-item-right>
I leave CSS experts tell you how you can achieve it.
Firstly accessibility isn't about what you want, never try to change expected behaviour.
When using a screen reader it is expected that items flow from left to right, top to bottom in 99% of cases (the way you would read the page normally).
The idea is that a screen reader user gets the same experience as someone who does not need to use one.
With regards to focus, never interfere with that either if it is something that is interactive (a clickable cell, link etc.).
If something is focusable it should also have a distinctive border (this helps users who use tab to navigate due to mobility issues know where their current cursor is placed on your site.) - just an extra tip, not relevant to your question.
The current read order is correct, do not interfere with it.
With regards to using arrow keys that may be useful, just use JavaScript to intercept the key presses and move focus accordingly (give that a go and post another question with a code example if you get stuck.)
Bear in mind you should also provide a way for people to disable this arrow key behaviour as they may have changed the key bindings on their screen reader and that would cause accessibility issues if your JavaScript interferes with their preferred key bindings.
I am not sure why you said you don't want to focus the element, if your custom HTML elements have focus in the first place then adjust those elements (as you must have added a tabindex=0 or some JS to those elements in the first place to make them focusable as <divs> are not focusable by default.)
I create an event structure for two buttons, start ROI and stop ROI. When the user presses start ROI it goes to this event and do the following:
check if the camera is open and is in idle
enqueue "none" to the queue to initialize the queue
in the loop dequeue every iteration to find if there's invoked message, which is inserted from the callback
if the element is "invoked" then update the region
The problem I am seeing is that when it is in the loop I cannot press the stop ROI or any other buttons. But the ROI keeps updating. I am puzzled why this is happening.
Could you please help me ?
Thanks,
Edit events for that case (the one pictured in your screenshot) and make sure the box titled "Lock front panel" is unchecked. This should solve your issue.
As far as I can tell from the code you have shown, your event structure should not be attempting to handle the stop ROI Value Change event. It doesn't need to, because the only place you need to respond to that event is inside your innermost loop and there you are handling the button click by polling the value of its terminal anyway.
However as #Dave_St explains, this will only work if the loop runs regularly, i.e. if the Dequeue Element function either receives data regularly or has a short timeout, because otherwise it will wait for data indefinitely and the loop iteration will not complete until the dequeue has executed. Having an event handler for the button click can't help here because it can't interrupt the program flow - the event structure only waits for an event to happen and then allows the code in the corresponding frame to execute.
More generally though, and looking at your front panel which suggests you are going to want to deal with further controls and events, the problem is that you are trying to do a time-consuming task inside an event structure. That's not how event structures are designed to be used. You should use a design pattern for your app that separates the UI (responding to user input) from the process (acquiring images from a camera) - perhaps a queued message handler would be suitable. This may seem harder to understand at first but it will make your program much easier to develop, extend, and maintain.
You can find more information, examples and templates in your LabVIEW installation and its online help. I do recommend using one of the templates as your starting point if possible because they already implement a lot of common functionality and can save you a lot of redundant effort.
Let's say I want to have an AtomicText blot that is similar to the default Link blot but is immutable and can only be removed as a whole. More specifically:
The cursor can be between the characters of AtomicText.
It is possible to select parts of AtomicText.
Deleting at least one character of AtomicText leads to the deletion of the whole AtomicText.
Adding characters to AtomicText is not possible once it has been created. Neither via keyboard events nor via copy and paste.
My idea was to make AtomicText extend from the Embed blot. In that case, the whole AtomicText blot is deleted when the cursor is right to its last character and backspace is pressed. But other operations do not work as expected. I assume I need to override some of the Blot methods to achieve the correct behavior but I am a bit at loss here.
Another idea is to listen to text-change events, determine if the cursor is inside an AtomicText blot and act accordingly. E.g., when pressing backspace, find the start and end position of the current AtomicText blot and remove all characters between these indexes. This seems to be a fragile approach.
Any pointers would be appreciated.
Similar questions/requests are the following:
How to make non selectable embed custom format in quilljs
How to add a non editable tag to content in Quill editor
Quill Editor: Restricted Editing based on tags/classes
I my experience setting contenteditable false is problematic. If you position the AtomicText blot at the end of the document you will not be able to append to it. Additionally, moving the cursor over the AtomicText positioned at the end will blur the editor.
I experienced a similar issue with a footnote blot. It's a sup tag that contains [\d+] and we don't want editors to modify the footnote but we do want them to be able to seamlessly move the cursor through them.
I have experimented with two other options in addition to the text-change listener mentioned by the OP. The first option is to attempt to position the cursor (via setSelection) in front or behind using selection-change event listeners. I found this to be problematic because it's possible to sneak characters in before the selection change event fires. I'm also not a fan of this approach because it causes the cursor to jump across the footnote. YMMV
Another option is to intercept keyboard input. You can add a keyboard listener (I used KeyboardJS) in a module that's initialized with quill. If the current selection is "inside" of your atomic text you can stop the input from proceeding to quill using e.preventDefault(). With this approach you'll also have to provide custom keyboard handlers in your quill configuration to override tab, enter, and possibly delete. Tabs are more of a challenge because there's a default tab handler provided by quill that takes precedence unless you override it. Within the custom handler you'll have to detect if the context is within your AtomicText. The context object will contain contain a format map that contains atomictext (your blot name) if it's in the context of AtomicText.
Note that if the user positions the cursor adjacent to your AtomicText, then from quill's perspective that's in the context of AtomicText. Our solution to that problem for input is to insert a zero width non breaking space, then allow the keyboard input to proceed. That "breaks" the cursor out of the AtomicText blot allowing insertion to proceed as expected. We then strip those characters out of the resulting HTML before saving the text.
Hope this helps.
In the blot create(value) function, add this:
node.setAttribute('contenteditable', false);
By experiment I found that Resize event is fired when Move is performed. Not only that, but Move action also preserves resize factors (so literally Move=Resize). In practice it means, when the form is being Moved (i.e. by user), and if another thread resizes it through BeginInvoke, it will get its original size (the one it had before movement started) when the next Move event happens.
Business use case/example: user opens a screen with dynamically sized ListBox, which contains dynamic list of items, whose population may take considerable time. Assuming loading takes place in a parallel thread and then BeginInvoke is called to update DataSource. When DataSource is updated, form size should change to accommodate all items on screen, if possible (if not, pagination will occur). With default approach, size update will have no effect if user was moving the form across the screen (to another screen would be best example) when the list finished loading, as it would automatically revert to original size.
Question: is it possible to somehow override Move or Resize behavior to consume that new size and not revert to the original one? Should I look into WndProc hacking?
Not sure if my answer would be useful 3 months late, but I got around this by handling the Form.ResizeBegin and Form.ResizeEnd events. These are called respectively whenever the user starts and stops dragging around the form on the screen.
In ResizeBegin event handler
beingMoved=true;
In the method called by BeginInvoke:
if(beingMoved)
needsExplicitSizing=true;
In ResizeEnd event handler:
beingMoved=false;
if(needsExplicitSizing)
this.Size = new Size(width,height);
Suppose I have a Window with TextBoxes I want to use the values. Right now I'm thinking of either:
1) Updating each associated value once the cursor is out of focus, and once the user presses Ok I start the program
2) Once the user presses Ok, I retrieve all the values at once then start the program
I'm not sure which one is better though. First alternative seems more modular, but there's more semantic coupling since I each new box is supposed to be updating its respective value.
I realize this isn't all that important, but I'm trying to understand when to centralize and when not to. Other better approachers are appreciated too.
Use data binding to bind the text boxes' contents to objects in your code behind. WPF will take care of updating your attributes. Usually updating the data-bound value is done when the focus is lost on text boxes. However, you can also specify that it will happen whenever the value changes.