GTK: TreeModel::iter_next returns false when there are more elements - gtk

I have a TreeView with a TreeStore, and it looks like this:
I get the selected row from the TreeView by calling get_selection and calling get_selected on the resulting TreeSelection. From this I obtain a TreeIter which should point to the selected row.
I expect either iter_next or iter_prev (from TreeModel) to be successful since there is another row at the same level, namely Hello. However, calling either of those iter functions on the selected iter returns false.
Have I misunderstood something?
The documentation for TreeModel::iter_next states:
Returns an iterator pointing to the node following iter at the current level.
And Hello and Hello 2 are evidently on the same level.

I found the problem. I listen for Shift+Up to do the operation I mentioned. However, it seems like GTK first acts according to the Up keypress so that when my node_up function is called, the focus has changed to the Help node.

Related

talend thmap get value of outer loop element

I'm just starting out with thMap.
So far I have successfully mapped an X12 835 message to output structures. That works no problem.
I have also successfully acquired the LoopIndex of the current loop using the LoopIndex() function.
My challenge:
I need to get the value of an element from the enclosing loop.
In the attached image, everything in green is working.
I'm trying to get the value down the red line.
My goal is to do this assignment
gsRecord.parent_id = enclosing loop isaRecord.id
The documentation explains some things but I don't see examples putting it together.
Does anyone have any good examples, videos or suggestions?
Update from 12/9/22
Here is something I have tried. Providing this example in hopes someone recognizes a specific issue to help move me forward. Any input would be appreciated.
Per this screenshot
I am attempting to output in gsRecord.parent_id the loopIndex of the parent loop (isaRecord).
This gives me the following error
"An reference in an LoopIndex/Variable was made to an either an input
map element or an output map element that is not in the context of the
reference. Use an enclosing looping output map element here.(msg #1202)"
Given the reference to 'enclosing looping output map element here' it feels like the gsRecord is not properly defined as a child of the isaRecord.
However the definition of the gsRecord is in reference to the isaRecord as in this screenshot.
It feels like there is some combination of LoopIndex and EnclosedContext that I could use to accomplish this but I'm unable to find any in-depth documentation on the functions.
Any help would be appreciated.

How to prevent cy.get from "snapshotting" a list before it's sorted

Not the best title, but here's my challenge. I have a list on my page that can be sorted, and I want a Cypress test that checks that it works as expected. So imagine this test:
/* 1 */ cy.get('.list-item').eq(0).should('have.text', 'A');
/* 2 */ cy.get('.list-item').eq(-1).should('have.text', 'Z');
// Code that triggers sorting to change from asc to desc
/* 3 */ cy.get('.list-item').eq(0).should('have.text', 'Z');
/* 4 */ cy.get('.list-item').eq(-1).should('have.text', 'A');
Looks simple, but there's a slight delay when the sorting happens, so the UI isn't updated immediately.
I'm not sure if it's the cy.get or the eq function which causes it, but the problem is that line 3 "captures" the first element in the list, which is still 'A', and then tries to assert that the text is 'Z'. And when the list is reordered, this "captured" element doesn't actually change, it's just moved in the DOM, so the assertion still tries to assert that same element 'A', which in the DOM is actually the last element now, is 'Z', which it obviously isn't and shouldn't be.
If I insert a cy.wait(100) before 3, then it works as expected, but obviously I do not want to have a random wait in my test, so how do I solve this?
How do I check what the first and last elements are in a situation like this, when Cypress captures the DOM elements before they're reordered, without inserting an arbitrary wait? 😕
Actual case
Support app, showing a list of the 5 most recently viewed clients
Need to test that, when visiting for example number 3 in that list, it is moved to the top
The "code that triggers sorting" is actually a route navigation event:
There's a listener (React useEffect hook) on route changes.
When route changes, it updates the list of recently viewed client ids, which is stored in local storage.
When the list in local storage changes, the component showing the list first waits 750ms (so it's less confusing for user, but turned down to 10ms in Cypress tests), then updates (re-sorts) the list.
And since the list only contains ids, each tile will then async load the name and some more stuff to display on the list item.
So... the delay is actually more than just a UI update. There's routing, local storage and async requests involved too. 🎉
You need to merge cy.get(...) and .eq into a single selector to make sure it retries the assertion .should('have.text', 'Z') after resorting. Read about it https://on.cypress.io/retry-ability#Merging-queries - right now it grabs the list and then only retries .eq() command, which is too late. You could also rewrite your code to get the first and last elements using single .should(cb) https://on.cypress.io/should#Function - the example in the docs really fits your use case.
I am taking a wild shot here, but perhaps in the trigger to sort you could use then.
cy.get('.list-item').eq(0).should('have.text', 'A');
cy.get('.list-item').eq(-1).should('have.text', 'Z');
// Code that triggers sorting to change from asc to desc
cy.get("#id-to-sort").click().then(()=>{
cy.get('.list-item').eq(0).should('have.text', 'Z');
cy.get('.list-item').eq(-1).should('have.text', 'A');
})

In SAP scripts how do you define which data is sent to an element

I need to make some changes to an SAPScript. I have the program and form name
Program: RBOSORDER01
Form: RBOSORDER02
I am looking to change some of the data shown in the form. I have debugged the program and I get see the call to write to the form, for example:
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ITEM_TEXT'
EXCEPTIONS
ELEMENT = 1
WINDOW = 2.
But how is the data passed between the program and the form. I cannot link between each. I was expecting to see a structure or a data element passed with 'ITEM_TEXT' and then this data is printed at this element "ITEM_TEXT" in the form but the link is not clear to me.
I have looked at the form also in SE71 and cannot see where you define this. Where is the link here, what am I missing?
This is in the form, so SE71 is what you need. You have to find the window first, where this element (ITEM_TEXT) is displayed, than look for the element and see what is displayed inside. The SAPSript form uses the global variables (structures, internal tables) of the print program directly by default (there are some other options as well, INCLUDE texts for example). So for example if a global variable gv_text is declared in the print program, and it is displayed in the SAPScript, than it will look like &GV_TEXT& in the form.
You can also debug the SAPScript if you switch on debugging in SE71 (can be painful, if the form is big).
Function 'WRITE_FORM' just calls the EntryPoint of the Form (SE71 / RBOSORDER02) in this case with ELEMENT='ITEM_TEXT'.
So you will end up in MAIN-Window at:
/E ITEM_TEXT
/: INCLUDE &VBDPA-TDNAME& OBJECT VBBP ID 0001 PARAGRAPH IT
In this case you have to debug what "VBDPA-TDNAME" is at this time and then you will find its value with transaction "SO10" (Standard-Text)
The INCLUDE can be a complex text and can have its own format strings.
As Jozsef said before, VBDPA-TDNAME is defined global in the print programm. (SE38n / RBOSORDER01)

Requesting member of node_element results in "undefined"

I'm using Opa for a school project in which there has to be some synchronization of a textfield between several users. The easy way to solve this, is to transmit the complete field whenever there is a change performed by one of the users. The better way is of course to only transmit the changes.
My idea was to use the caret position in the textfield. As a user types, one can get the last typed character based on the caret position (simply the character before the caret). A DOM element has an easy-to-use field for this called selectionStart. I have this small Javascript for this:
document.getElementById('content').selectionStart
which correctly returns 5 if the caret stands at the fifth character in the field. In Opa, I cannot use selectionStart on either a DOM or a dom_element so I thought I'd write a small plugin. The result is this:
##extern-type dom_element
##register jsGetCaretPosition: dom_element -> int
##args(node)
{
return node.selectionStart;
}
This compiles with the opp-builder without any problem and when I put this small line of code in my Opa script:
#pos = %%caret.jsGetCaretPosition%%(Dom.of_selection(Dom.select_id("content")));
that also compiles without problems. However, when I run the script, it always returns "undefined" and I have no idea what I'm doing wrong. I've looked in the API and Dom.of_selection(Dom.select_id("content")) looked like the correct way to get the corresponding dom_element typed data to give to the plugin. The fact that the plugin returns "undefined" seems to suggest that the selected element does not know the member "selectionStart" eventhough my testcode in Javascript suggest otherwise. Anyone can help?
In Opa dom_element are the results of jQuery selection (i.e. an array of dom nodes). So if I well understood your program you should write something like node[0].selectionStart instead of node.selectionStart.
Moreover you should take care of empty selection and selection which doesn't contains textarea node (without selectionStart property). Perhaps the right code is tmp == undefined ? -1 : tmp = node[0].selectionStart == undefined ? -1 : tmp

Webdriver kicks the bucket on "find_element"

I am using the Ruby interpretation of Webdriver. Now the webpage I am looking at may or may not contain a certain element. If it doesn't I would like to look for another element. However, whenever Webdriver can't find an element it throws an exception.
My question is, can I check to see if the element even exists on the page without littering my code with begin/rescue blocks ?
Any help is greatly appreciated.
The short answer is no. To check if element exists, you have to rescue errors. find_element always throw NoSuchElementError if element was not found. You can for example take a look at implementation of #exists? method in Watir-WebDriver.
Still, you can use find_elements method which will return empty array if not elements were found.
elements = #browser.find_elements(id: 'doesnt-exist')
if elements.empty?
# go to the next element
else
# work with element
element = elements.first
element.click
end