Powerapps - Unable to change Toggle on separate screen - toggle

I'm trying to use toggles on an inactive screen as a replacement for functions (and thus help code reuse), however I'm stuck as my toggle won't activate unless I visit the page it's on. I found plenty of working examples online but somehow can't get it to work for me.
Overview:
I have a button on screen1 and a toggle on screen2.
During my button's OnSelect event, a variable varSendData is being set to true like so:
Set (varSendData, true)
The toggle has its Default property set to varSendData.
The OnCheck property of the toggle contains the code to be executed:
Notify("This works")
Problem:
While the variable varSendData is correctly being set to true, nothing happens while I'm on the screen1 with the button. Only when I visit the screen2 with the toggle (even if in edit mode only) does the toggle change state and execute the code in the OnCheck property. I tried using the OnChange property of the toggle, however that has the same effect/limitation.
Furthermore, if I set the variable (varSendData) back to false before visiting screen2 then nothing happens from which I conclude that the toggle is only triggered (changed) if the page it's on is visible/active.
Any ideas on how I could get the toggle to change state even if I'm not screen2? Or any other ideas on how I could reuse the same code from different screens?

It's a limitation of the method the actual code is calling. In order to allow the HTML to refresh from this "Notify("This Works"). You would need to also have a function that refreshes the HTML in the screen your currently viewing.
I was able to get this to work by adding a label and setting its text property to be If(Toggle6.Value = true, "yes", "no").
Literally adding this in allowed the notification to pop up. Nothing extra.

Related

Button Is Disabled but Still Listens to Press Event

I have a submit button in a <VBox>. On press of it, I have an order creation process. If I click multiple times on the button, multiple orders are created. Is there a way I can disable it after the first click?
I have written the following code in my controller, but it seems to be still hearing to the press action:
onSubmit: function(oEvent) {
this.getView().byId("save").setVisible(false);
//......
},
But this does not disable completely. Though in console, when I check using getEnabled(), it is set to false. How to stop the button from listening to press event when disabled?
I can suggest the following solutions:
Right after the button got clicked - set its "enabled" property to "false" via property binding against JSON model. Once the async action got executed (i.e. success/fail callbacks) - release the button state by setting "enabled" to "true"
Right after the button got clicked - set its "busy" property to "true" (do not forget to set the "busyIndicatorDelay" to 0. The releasing concept is the same as for point 1.
In my opinion, these approaches are more UI5 specific. Personally I would choose the option 2, as it shows the state of processing something in a more prominent way to the user.
Well I think the problem is that setVisible is not the same as enables/disabled.
Maybe you could try to change
setVisible(false);
to
setAttribute("disabled", true);
Hope the bellow code will work fine. Making SetVisible(false) you just hide the button.
Controller: onSubmit: function(oEvent) { this.getView().byId("save").setAttribute("disabled", true);
check this: https://www.webdeveloper.com/forum/d/147187-how-to-disable-enable-submit-button-using-javascript
for detail understanding

DOM usage in QTP

During script execution a pop up won't go away, and it happens only through QTP(v12.02).
I am trying DOM to bypass the problem, the pop up event was on selection of a drop down value, so I used some code to find the correct index and use DOM to select the value
Browser().Page().WebList().Object.selectedIndex = itmindx
With this the pop up issue got resolved, but now to complete the process,I need to click the Save button which is disabled as the page didn't refreshed when the value was selected ( tried refreshing through QTP, tab out etc--didn't worked as it loads the previous value).So I used the fire event method
Browser().Page().WebList().Fireevent "onchange"
with this I ran in to the same issue of multiple pop ups. Used the following
Browser().Page().WebList().Object.onchange()
but then QTP won't executes the next line unless I hit enter externally on the pop up(multiple pop up is resovled but now QTP is stuck. I don't want to use RS.... Any solutions?
To enable the button
Browser().Page().WebButton().Object.disabled = false
Or
To hit enter for the popup
CreateObject("WScript.Shell").SendKeys("{ENTER}")
[ http://ss64.com/vb/sendkeys.html ]
Go for hitting the Enter button using SendKeys. It is not a good idea accessing DOM and change the state ourselves. There is a chance that you might miss potential defects!

How to create a 'non-binding' binding in MVVM?

My question is very close to this one:
How can I switch tabs programatically from within my ViewModel?
But what I want to do is just switch tabs as a courtesy to the user, and not make it binding. (When the user starts a 'scan', I would like to switch to the 'monitoring' tab, but not prevent him changing tabs just because the scan is still running).
I've worked out that setting mode=OneWay will avoid the user stopping the scan by changing tabs, but my original idea of binding to 'Scanning' doesn't work great because when that gets set to 'false', the tab goes to 'not selected' and I just get a blank rectangle. I could only invoke the 'property changed' when it goes from false to true, but that seems very wrong.
I ended up deciding that code behind was the best way to go. It's a UI convenience for the user and the ViewModel doesn't need to know anything about it. So I hook into the 'Start' button and switch tabs when it's clicked.

How to programmatically press toolstripbutton down?

I want to push toolstripbutton down in my code and I can't seem to be able to do that. I know on Delphi RAD Studio or XE, you can do the following and cause the button to be pressed.
ToolStripButton1.Down := true;
The only ToolStripButton property I see that comes close to "down" is checked true or false. If I do set it to true, it only highlights the toolstripbutton not press it down.
Here is how the button looks when I put my mouse on it and click:
You can clearly see that the Zoom In button is down.
Here is how the button looks when I try to do the samething through my code by setting CheckOnClick true and Checked true.
In this image, the only thing you can see is the blue box around it. I suppose if I had used just the text on the button, you will see that the whole button filled with blue color to show that it was pressed.
I also have toolstrip button in my other program which acts the same way but I had to use imagelist control to switch between pressed or down or checked verses not pressed or down or checked.
So, is there a way to press the ToolStripButton programmatically in Delphi Prism or C#?
Set the ToolStripButton.CheckOnClick property to True. (It's found in the Behavior section of the Items Collection Editor.)
This makes clicking it just like toggling the Down property in a Delphi TSpeedButton (making it flat or depressed), and if ToolStripButton1.Checked is the equivalent of if SpeedButton1.Down in Delphi.
To set up the test, I did the following:
Created a new Winforms application
Dropped a ToolStrip onto the new MainForm
Added four ToolStripButton items and gave them images to make them easier to see.
Set the CheckOnClick property to True for each of them
Set the Checked property of toolStripButton1 to True;
Added the code below to toolStripButton1.Click
method MainForm.toolStripButton1_Click(sender: System.Object; e: System.EventArgs);
begin
toolStripButton2.Checked := not toolStripButton2.Checked;
toolStripButton4.Checked := toolStripButton2.Checked;
end;
Running the app (initial startup, toolStripButton1 checked and the others unchecked):
The first button is clearly down, and the rest are up.
After clicking toolStripButton1 once:
The first button is now up (unchecked) and the second and fourth are down (checked). (I should pay more attention to the consistency in sizing if I do successive images in future posts.)
If have placed this code in the preceding control in the 'Leave' event.
Private Sub PurposeComboBox_Leave(sender As Object, e As EventArgs) Handles PurposeComboBox.Leave
Me.AppliancesForSelectedFunctionToolStripButton.PerformClick()
End Sub
I do not know if you could place code in Form Load or not.
Hope this helps.

JavaScript: How to force a page reload on reset?

I have a page with some generated HTML that survives the form's reset button. It is a problem because that HTML is inconsistent with the values in the cached default form.
In principle I guess it could be solved easily if I could force a hard reload from the server when the user presses the reset. However I see that the Chrome browser does not support the onReset event (in fact it is deprecated in HTML5).
But perhaps I could work around the missing onReload event. Can I re-define what happens when the reset button is pressed? In my case the apply and reset buttons are located in general HTML templates which I cannot change. Can I attach a function to the button from JavaScript?
You can replace the "reset" button , by a regular button.
And use the "onClick" event, to trigger a page reload.
EDIT
oops I missed the template part,
You can add a function to a button from Javascript.
First you need to "get" the button, with something like document.getElementbyId('resetButton');
If the button doesn't have a ID, you still can to retrieve it by doing javascript dom traversal
then you can add a function like :
var resetButton = document.getElementbyId('resetButton');
resetButton.onclick= reloadPage;
function reloadPage(){
window.location.reload();
}