Inside a loop I change the text of a textfield. But corona does not render until the loop is finished. Is it possible to force a render inside a loop?
I have tried with display.setDrawMode( "forceRender" ) and to do a sleep in the loop but it does not matter. Im trying to do a progressbar that updates.
Corona only renders between your event handlers. While your handler loops, Corona cannot update the display. Basically all commands in your handler than affect the display take effect only after the handler returns control to Corona. So if you want to show a value change repeatedly in a text field, you can't use a loop, only last change to the value will be visible on display, and only after return.
Therefore, you need to use one of Corona's mechanisms to cause the update to occur again. For example, you could listen for Runtime's enterFrame event; in there, determine if it is time to update the value and/or the text field and act accordingly. If this leads to too many updates (it will be 30 or 60 times per second), then another way would be to schedule an update of text field for later, as suggested by Frozire:
function updateValueDisplayed()
...compute new value...
...if changed, update the display object that shows the value...
end
timer.performWithDelay( 500, updateValueDisplayed, -1 )
The above will call updateValueDisplayed twice per second, until you exit. If the delay should be different every time, or should stop under certain conditions, then you could performWithDelay only once (remove third call parameter) and call timer.performWithDelay( delay, updateValueDisplayed) from within updateValueDisplayed as appropriate.
Clarification: you can't use a for loop. You can only use a repeated function call, two ways are described above.
Related
I am writing a code using playwright test and its working fine in debug mode but normally its not able to find the element because not able to scroll down the page., I have tried using scrollintoview and mouse.move funtion as well.
You can use locator.focus() instead which will do the scrolling for you.
await locator.focus();
If you want to perform the click operation on that element, then page.click() function internally scroll into view to the target element.
Reference:
https://playwright.dev/docs/api/class-page#page-click
page.click(selector[, options])
This method clicks an element matching selector by performing the following steps:
Find an element matching selector. If there is none, wait until a matching element is attached to the DOM.
Wait for actionability checks on the matched element, unless force option is set. If the element is detached during the checks, the whole action is retried.
Scroll the element into view if needed.
Use page.mouse to click in the center of the element, or the specified position.
Wait for initiated navigations to either succeed or fail, unless noWaitAfter option is set.
I've noticed that at times the onMouseOver(e) function gets triggered when I hover over my chart but other times the onContainerPointerMove() function gets triggered. How do these 2 differ? What triggers each function? Can the trigger event be changed?
Reference for onContainerPointerMove function: https://github.com/highcharts/highcharts/blob/master/js/parts/MSPointer.js
There doesn't seem to be documentation for the onContainerPointerMove function in the API reference.
First of all, onContainerPointerMove is an internal Highcharts function and that is why it is not documented.
As the name suggests, onMouseOver is fired when the mouse pointer enters the element or one of its children. onContainerPointerMove is called on every poiner move over the element.
I have this tool tip that is created every so often. What is the appropriate actionscript etiquite?
A. To Create and remove the tooltip moveclip when needed?
or
B. To hide and show the tooltip movieclip when needed?
With these A and B, the answer is B, because creating and then removing an object a lot of times creates a lot of garbage in the memory, which eventually leads to garbage collector calls, that slow your SWF's performance. You can easily go with a single tooltip MC, just fill it with information that corresponds to the new mouse coordinates before you show it.
There is another question, not so straightforward as yours, about how to hide and show a movie clip, either via visible property or via addChild() and removeChild() (AS3 only). If you are using AS2 or AS1, use visible property to hide and show your tooltip.
There are three ways to hide something in Actionscript : Alpha, visible and remove child.
Apha: If you turn the alpha zero the renderer always comes to this displayObject and renders it at alpha zero. So the object is always rendered you just cannot see it.
Visible == false In this case the object still exists in your displaylist. So the renderer comes to the object. Sees it's property is false and leaves it but it still exists in the display list.
removeChild This means that you're removing the object from the display list. This means that the renderer never had to even check for it. Which makes it the fastest option.
addChild doesn't take that much computing power as visible check. I'm sure you can find benchmarks on this.
If you don't have a lot of objects on yours screen and the tooltip is there every second I'd go with visible is false. In all other cases go with the third option.
On a side note, I've found it always easier to manage them with a toolTipManager. A class that makes sure that you have one tooltip on the screen because usually users only use one tooltip. So that makes things easier for me. I just always create the necessary tooltips and add them to the displaylist when required and remove them. (Not recreate them) At the same time have only one tooltip on stage.
I thought OnSetEditText was fired whenever text in a cell changed. After setting a breakpoint and experimenting, I know that's wrong :-) So, first, when is this event fired?
Second, if I would like to have the text inside a grid cell continuously autosized, which event should I be coding to make this happen (note: I am using TMS's string grid derivative which includes a method for autosizing rows; I just have to figure out when to call it)?
The OnSetEditText event is fired every time the user changes the contents of the in-place editor control, assuming, of course, the control is editable (goEditing in Options). This is confirmed by the documentation, the VCL source code, and black-box verification.
I have a Delphi 6 app with a TListBox control set to lbOwnerDrawVariable. At run-time I add a single string to the list box. I have event handlers for OnMeasureItem() and OnDrawItem() and I set breakpoints on the very first line of code in each event handler. However neither of them are ever called. Not once. Not even if I make an Explicit Refresh or Repaint call on the list box.
This is really basic stuff so what is it that I am doing wrong that could inhibit the calling of those event handlers and subsequently disrupting my owner draw code? The single string does show in the list box properly. I threw in an OnClick() event handler just to see if it worked and did.
The OnMeasureItem and OnDrawItem events are (indirectly) triggered in response to the WM_MEASUREITEM and WM_DRAWITEM messages from Windows. Make sure you do not have any message handlers in your app that are filtering out that message, or the VCL's internal CN_MEASUREITEM and CN_DRAWITEM messages.
It turns out the problem was due to a non-zero value in the Columns property of the TListBox I was using. I had been experimenting with using columns earlier before I converted over to owner-draw and had left the TListBox.Columns property with a non-zero value. Apparently a non-zero Columns property value inhibits the triggering of owner-draw related event triggering. Once I set that property back to zero OnMeasureItem() and OnDrawItem() started firing.
There's really very little that can go wrong here. If you set up a test app to try this out then it functions just as you would expect and the event handlers are called.
The most likely cause of the behaviour you report is if the items are added before the event handlers are assigned. This typically happens if the items are added at design time in the .dfm file. You say you are adding the items at runtime. Perhaps you are adding them too soon, before the event handlers are assigned. What happens if you add items in response to an event, e.g. a button click. Try that out because you can be sure then then the event handlers are assigned by that point.
If that doesn't help then clearly you have some code in your app that is interfering with the VCL code.
I had this same issue: my OnDrawItem event handler was not being called if the Columns property was non-zero. It turned out this was because the Style property was set to lbOwnerDrawVariable. Variable item height is not allowed in conjunction with multiple columns, presumably because the rows would not line up across the columns if the item heights were allowed to be different. Once the Style property was set to lbOwnerDrawFixed the OnDrawItem event handler was called as expected.
I had a similar problem with a csOwnerDrawVariable-style combobox not triggering the OnMeasureItem event. As David Heffernan suggested, the issue was that the items had been added to the list at design time. The work-around I ended up using was to add code to the FormCreate event handler to copy the design-time list to a temporary variable, then clear the list and add the items back. Kludgy but effective.