addHandler to a webTextField in a container

I have something strange
There is a container(rccMMM) with a webTextField(myWebTxtf) and a webButton.
myWebTxtf has an event doubleClick and open.
I embed this container in a Webpage and add a Handler

dim c as new rccMMM c.EmbedWithin(self,0,0,c.Width,c.Height) AddHandler c.myWebTxtf.keypressed, AddressOf myHandler

When I enter something in the textfield and Enter, myHandler is handled.

I do the same with a WebDialog

dim wd as new myWebdialog wd.show
The event shown of wd places/embed the rccMMM
When I enter something in myWebTxtf and press Enter, he doesn’t move.

Is there something special about a WebDialog, that I don’t know?
How can I debug what he does?

Okay, no reaction…!!
Therefor I made a little App to demonstrate what is happening

Is there anybody out there who could have a look at this App, and tell me why the same thing doesn’t function on a Webdialog and on the other hand functions on a webpage.

I could send it to your Email address.

[quote=244622:@roland brouwers]Okay, no reaction…!!
Therefor I made a little App to demonstrate what is happening

Is there anybody out there who could have a look at this App, and tell me why the same thing doesn’t function on a Webdialog and on the other hand functions on a webpage.

I could send it to your Email address.[/quote]

Why not put the project on dropbox and post a link ?

I looked into it, though. Apparently, addhandler indeed does not work in the Open event of the dialog.

However, if you add the event handler to the TextArea in the IDE, it works as expected.

My dropbox account gives me problems
Can you goto
http://catbe.dyndns.org:800/xojo/
and download
testWebAddhandler.xojo_binary_project

When you start the app there is a yellow TextField which handels alright
Pushing the button will start the WebDialog where the yellow textField doesn’t react.

Indeed addhandler does not work on the dialog.

You should file a bug report.

But as I said above, if you add the event handler in the IDE, it works just fine. Since you place the TextField in the IDE, it is a very simple workaround.

The way I work is as follows:
There is a listbox
I click on a row and call a WebDialog(fieldnumbers)
The Webdialog will display all the fields defined by fieldnumbers, retain the record DataBaseRecord in the rowTag
and replace the textfields by containers if necessary
If p.e. there are 5 Fields in a record I will put 5 TextFields on screen and the corresponding containers(radiobuttons, comboBox etc.), The TextFields will be set invisible.
After entering Data the results of the containers will be copied to the textfields, which will be written to the database.

This is all standard procedure.

Everything that is not standard will be done with routines outside the WebDialog = AddHandler
The handler will execute in the environment of his calling WebPage or WebDialog, where variables will be local and protected.

So, if you ask me to do something, that is non-standard, to put in a standard environment, I have a problem.
I will have to make a Webdialog for every table or every variation.

That’s why Handlers are so important.
Maybe I’m not as far to find a solution which goes behind my knowledge of Xojo.

What do you exactly mean by:
if you add the event handler to the TextArea in the IDE

Right click on the TextField, select “Add to WhateverTextField…”, select “Add event handler”, and in the list, select Keypressed.

He Michel,

*** As if I don’t know that. ***

But that is what I don’t want. See my explication, clarification above.

I repeat, I would like to have one Methode, which handels or unfolds a webdialog in a standard way, and leaves all the specifics to methods (= addressed Handlers) of the calling Webpage or Class.

Therefor Handlers or a very nice way of keeping things isolated and a possibility to jump from a satellite down to Earth, in human words, a connection from standard floating methods to webpages(classes) containing privat/protected variables/methods/properties.

NO NEED FOR SARCASM

You got a bug, work around it. Or dance on your head. I could not care less at this point. I understand why nobody chimed in.

Listen, Michel,
I worked for more then Two Years to build a standard which is based on Handlers.
Now you’re telling me to work around it. What is the workaround for a not-Handler?

The only work around is to build the code directly in the standard code, which makes the code not standard.

This is not a bug, this is a BIG BUG.

If I work around it, I will have to rewrite the entire code once they have fixed it.

I already lost a couple of weeks because the cells in a WebListBox are not editable.

I’m NOT SARCASTIC, I’m tired and out of schedule.

We’re all here voluntarily. If you find a bug, report it. That’s all there is to it.
We can’t fix bugs, we can only point them out and help you work around them.

I’m not entirely sure what you’re trying to do because of the language barrier, but it kind of sounds like a workaround for subclassing and using your own constructor (I don’t know if it’s possible in Web - I haven’t tried)

If you’d like to have a solution made for you, it may be time to hire someone.

Hi Roland.

The biggest problem is that you’re reaching inside of your container and dialog to attach handlers to their internal controls, this is a big no-no in the world of object orientated programming, the container or dialog should be treated as a “black box”. Instead, you should only use the properties and events that the container and dialog expose.

Define an event definition on your container…

Event TextChanged(value As String)

… and then raise that event from the control inside the container…

Sub TextChanged() RaiseEvent TextChanged(me.Text) End Sub

When you create an instance of the container you then use AddHandler on the exposed custom event…

Sub Shown() dim container as new TextChangedContainer container.EmbedWithin(me, me.Width - container.Width - 20, 20, container.Width, container.Height) AddHandler container.TextChanged, AddressOf me.ReplaceOutput End Sub

In the above example, the Shown event for a WebPage embeds a container and redirects its TextChanged custom event to the page’s ReplaceOutput method.

The same thing goes for WebDialogs, define an event definition that you raise from inside it, then handle the event in just the same way…

Sub Action() dim dialog as new TextChangedDialog dialog.Show AddHandler dialog.TextChanged, AddressOf self.ReplaceOutput End Sub

In the above example a WebButton on the same page’s Action event opens a new dialog and redirects the TextChanged custom event to the page’s ReplaceOutput method.

I’ve uploaded an example project that shows how to do this kind of thing.

https://dl.dropboxusercontent.com/u/6199282/AddHandlerWebDialogTest.zip

Hope that helps.

First of ALL I would like to apologize to Michel for my let’s say ‘uncontrolled’ reaction. I know it is nobody’s fault and I shouldn’t blame anyone. The only one to blame is me
[h]So, Sorry, sorry Michel[/h]

Stress, too many hours and bad luck … and out of schedule

Ian,

I thank you for your extended answer. And I do agree with the BlackBox theory.
But:
Suppose you have a Listbox in a container. This container will be filled with rows coming from a database Table. When a row is chosen by clicking on it, it will call a WebDialog which will present the row field by field, like a screen entry.

So, we have a Webpage, which will embed the container with the listbox and fills it with rows from a database Table.
Click on a row will start this WebDialog and treat every field in a standard way, dictated by standard methods(which are in a Module, that is used by different Webpages).

Webpage <=> handle <=> Container-Listbox <=> handle <=> Webdialog
To my opinion it is difficult to stay in one blackbox.

[quote=244928:@roland brouwers]
To my opinion it is difficult to stay in one blackbox.[/quote]
When you use AddHandler as the API design it definitely is
Addhandler is a tool to achieve a design goal - but its not a design in and of itself

As Ian points out reaching inside one container to get at other events is a design that will lead you to problems

I try to follow your way of thinking, which is probably the right way.
But how can I do what I described before.
Embed a container with a listbox and fill it using standard methods.
Then call a WebDialog which will treat the row field by field and give the result back to the container. The Webdialog will be out of the container. So the link is the addHandler.

Or am I missing something.

I admit after 3 Years I haven’t find a satisfying way.

Don’t forget that we use standard 4 languages in Europe, at least in Belgium we do.

Events & methods
Events are not only for keyboard handling etc
To return values to the container the dialog can raise events that the container can react to
And it can ask the container for information by raising an event that the container can implement & return a value

Suppose the dialog wants to know the name of the webpage its on
The dialog can use an event (pagename) to get this from the containing web page
So on the webdialog class you have a new event definition

event PageName() as String

on the dialog you want to use this as if its just a method so you might wrap it in a private method on the dialog itself

function PageName() as string
    return raiseEvent PageName
end

And now in any code on your dialog where you need the page name it on you can do

     dim s as string = me.pagename() + " whatever else I want"

like this http://great-white-software.com/miscellaneous/WebFoo.xojo_binary_project.zip

notice how events are used to get & send information back & forth between the dialog & containing page

I think I understand.

The only thing what I don’t understand is the fact that you drag the WebDialog in the IDE.
Isn’t that the same as
dim wd as new Webdialog1

If this is the same, then I’m using the same design.
I define events
I define a method in the calling window = methodInWindow
wd = new Webdialog1 [ wd is a property of the window ]
addhandler wd.eventdefinition, addressOf methodInWindow
I raise the event in the WebDialog or whatever.

I hope my explanation is correct.

[quote=244949:@roland brouwers]I think I understand.

The only thing what I don’t understand is the fact that you drag the WebDialog in the IDE.
Isn’t that the same as
dim wd as new Webdialog1

If this is the same, then I’m using the same design.
I define events
I define a method in the calling window = methodInWindow
wd = new Webdialog1 [ wd is a property of the window ]
addhandler wd.eventdefinition, addressOf methodInWindow
I raise the event in the WebDialog or whatever.

I hope my explanation is correct.[/quote]

That would seem to be similar but at one point you said you were hooking the events of controls IN the dialog itself

dim c as new rccMMM
c.EmbedWithin(self,0,0,c.Width,c.Height)
AddHandler c.myWebTxtf.keypressed, AddressOf myHandler

thats what I’d worry about

Yes, you’ve got it right Roland.