ChangeForm: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 3: Line 3:
== Description ==
== Description ==


''Visual effects added in AppStudio 5.''
ChangeForm hides the current form and shows ''newForm''. When the current form is hidden, its onhide() function is called. When the new form shows, its onshow() function is called. The global variable [[NSBCurrentForm]] is set to ''newForm''.


ChangeForm hides the current form and shows ''newForm''. When the current form is hidden, its onhide() function is called. When the new form shows, its onshow() function is called. The global variable [[NSBCurrentForm]] is set to ''newForm''.
''newForm'' is the variable referencing the form.


''hideEffect'' is the effect to use to hide the old form. It can be 'hide' (no effect), 'fade' or 'slide'.
''hideEffect'' is the effect to use to hide the old form. It can be 'hide' (no effect), 'fade' or 'slide'.
Line 13: Line 13:
''speed'' is the time to perform the effect. It can be 'slow', 'fast' or number of milliseconds. If it is not supplied, it will take 400 milliseconds, just less than half a second.
''speed'' is the time to perform the effect. It can be 'slow', 'fast' or number of milliseconds. If it is not supplied, it will take 400 milliseconds, just less than half a second.


== Example (Basic) ==
== Example ==
 
<tabber>
JavaScript=
<syntaxhighlight lang="JavaScript">
//ChangeForm sample call
 
ChangeForm(Form2)
  // or...
ChangeForm(Form1, "slide", "slide", 1000);
 
Form1.onhide = function() {
  alert("Old Form Hidden");
}


<pre>
Form2.onshow = function() {
  alert("Show form " +  NSB.currentForm.id);
}
</syntaxhighlight>
|-|
BASIC=
<syntaxhighlight lang="vb.net">
Rem ChangeForm sample call
Rem ChangeForm sample call


ChangeForm(Form2)  'or
ChangeForm(Form2)  
 
  'or
ChangeForm(Form2, "slide", "slide", 1000)         
ChangeForm(Form2, "slide", "slide", 1000)         


Line 29: Line 48:
   console.log("Show form " & NSB.currentForm.id)
   console.log("Show form " & NSB.currentForm.id)
End Function
End Function
</pre>
</syntaxhighlight>
</tabber>


Use a variable to change forms:
Use a variable to change forms:
<pre>
<pre>
   ChangeForm(window["Form" & i])
   ChangeForm(window["Form" & i])
</pre>
== Example (JavaScript) ==
<pre>
//ChangeForm sample call
ChangeForm(Form2);    // or...
ChangeForm(Form1, "slide", "slide", 1000);
Form1.onhide = function() {
  alert("Old Form Hidden");
}
Form2.onshow = function() {
  alert("Show form " +  NSB.currentForm.id);
}
</pre>
</pre>



Latest revision as of 13:43, 24 July 2019

ChangeForm(newForm[, hideEffect[, showEffect[, speed]]])

Description

ChangeForm hides the current form and shows newForm. When the current form is hidden, its onhide() function is called. When the new form shows, its onshow() function is called. The global variable NSBCurrentForm is set to newForm.

newForm is the variable referencing the form.

hideEffect is the effect to use to hide the old form. It can be 'hide' (no effect), 'fade' or 'slide'.

showEffect is the effect to use to show the new form. It can be 'show' (no effect), 'fade' or 'slide'. If showEffect is not specified, it will be the same as hideEffect.

speed is the time to perform the effect. It can be 'slow', 'fast' or number of milliseconds. If it is not supplied, it will take 400 milliseconds, just less than half a second.

Example

//ChangeForm sample call

ChangeForm(Form2);  
  // or...
ChangeForm(Form1, "slide", "slide", 1000);

Form1.onhide = function() {
  alert("Old Form Hidden");
}

Form2.onshow = function() {
  alert("Show form " +  NSB.currentForm.id);
}

Rem ChangeForm sample call

ChangeForm(Form2) 
 'or
ChangeForm(Form2, "slide", "slide", 1000)        

Function Form1_onhide()
  console.log("Old Form Hidden")
End Function

Function Form2_onshow()
  console.log("Show form " & NSB.currentForm.id)
End Function

Use a variable to change forms:

  ChangeForm(window["Form" & i])

Output

(msgbox showing "Old Form Hidden")

(msgbox showing "Show form Form2")

Related Items

Form