#1 2017-05-21 05:01:10

reg4app
Member
Registered: 2016-05-16
Posts: 147

Can I call other control's Event?

For example
How can I trigger Button2's Click Event in Button1's Click Event?


Joshua.Y

Offline

#2 2017-05-21 08:15:00

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: Can I call other control's Event?

Hello Joshua,

Please, take a look at the "External" app sample, and, particularly to the "Button2" "Click" event. Take also a look at the External Javascript tutorial.

Offline

#3 2017-05-21 09:53:16

reg4app
Member
Registered: 2016-05-16
Posts: 147

Re: Can I call other control's Event?

OK,Got it


Joshua.Y

Offline

#4 2017-09-26 20:14:50

webz
Member
Registered: 2016-02-12
Posts: 6

Re: Can I call other control's Event?

Hello David,

I've looked at a couple of your examples including 'SimulatePress', however I can't seem to find any reference to how you would fire the 'File Control' the same way a 'Label Control' would by putting the 'File Control' Behaviour Name into the 'Label Control' Visual Input field.
If JS is the way, is a variation on the following code whats needed 'window.App.NewView1.Scope.Input1Click();' or is the 'File Control's 'Input1.Event' the better approach?
The goal is (by adding variables) to use one 'HTML Control' to select more than one file (one after the other using multiple 'File Controls') on the users local storage.
Any help would be much appreciated.

Offline

#5 2017-09-26 21:43:12

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: Can I call other control's Event?

Hello Alex,

Thanks for posting. I am not sure if can understand very well exactly what you wanted or need, since, you talk about files but also about the app's local storage. Please, in order to try to help you, can you say if what you want is to upload one or more files to an app's server? Did you know that we can already use more than one Input File control in an app's view?

Certainly, everything we can do in Javascript is also suitable in our AB applications, but, I am not sure if we really need some external JS here or what. Additionally, if you think that you can explain a little more what you need to do, maybe, in addition to some specific help, we can also start to think into another possible approach to do what you wanted.

Offline

#6 2017-09-26 22:39:00

webz
Member
Registered: 2016-02-12
Posts: 6

Re: Can I call other control's Event?

Thanks for getting back so quickly. Currently I have my 'File Control' named 'Input1' placed outside the viewable area. In the view I have a 'Label Control' with 'Input1' in the Visual Input field in the properties nothing else. This opens up the users local file browser when you select the label at runtime.
I would like to remove the 'Label Control' and replace it with a 'Html Control' to achieve the same result at runtime! My intention is to use an array connected to the 'Html Control' to fire multiple 'Input File Controls'.

Offline

#7 2017-09-27 05:39:48

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: Can I call other control's Event?

Hello Alex,

The "connection" between a Label and an Input control (no matter if they are a File Input or any other) is the "for" attribute in the label element. That is, certainly is possible to add a label in an HTML control in that way, for example:

<label for="MyInputName">Press here!</label>

Note, however, that the Input File control is a bit special, in the sense that some browsers (the WebView on Android 4.x, for example) disallow to play with non visibles Input File controls. What you can do to pass around this is to place the Input File control(s) below than other controls (using the "z-index" CSS rule) in order to set it non visible, but wihout hide it completely.

Alex, at this point I am not sure if the above can be enough for you. Please, don't hesitate to post here any further questions that you have and I will try to help you. Almost always we can try several approachs to get what we wanted. For example, I am not sure why to use an HTML control here, since we can place any controls in a view in order to be "scrolled down": look a look at the "InputScroll" and "InputScroll2" samples.

Offline

#8 2017-09-27 19:34:38

webz
Member
Registered: 2016-02-12
Posts: 6

Re: Can I call other control's Event?

That's great! It seems to do what I am after, thanks. Going to test it a little more. I have the label wrapped around a table within the 'Html Control' Visual Input field. It messed with the layout a bit until the first entry in the table is acquired ie. Input1; but am sure I'll figure it out.
Will also look at the 'z-index' CSS rule. I had the test app fail opening up the local file browser on older devices but seemed to work fine on newer ones. Do you have an app sample or tutorial that demonstrates or refers to this 'CSS rule'?

Thanks again David, App Builder is awesome!

Offline

#9 2017-09-27 19:49:05

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: Can I call other control's Event?

Hello Alex,

Thanks for your kindly words. Please, take a look at this app sample. In the sample you can see two things: how to use an Image control and their "z-index" CSS rule in order to place on top of certain Input File control. Doing this we no need to hide the Input File control, who can cause problems, as you know, in older browsers. The sample also show how we can launch the Input File "dialog" using a label and also programmatically using the Image control's Click event.

Hope that sample can be useful for you, Alex, and, please, don't hesitate to post any other questions you have.

Offline

#10 2017-09-27 20:06:15

webz
Member
Registered: 2016-02-12
Posts: 6

Re: Can I call other control's Event?

Thanks will do! - that Javascript may also come in very handy as an alternative to the 'Label for' also... smile

Offline

#11 2017-09-27 20:35:26

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: Can I call other control's Event?

Hello to all,

webz wrote:

Thanks will do! - that Javascript may also come in very handy as an alternative to the 'Label for' also... smile

You're welcome Alex!

Offline

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.