Problem with Door-Library on Device

CryoGenID

Active Member
Licensed User
Longtime User
Hello everybody!

It's me again and I have (well what else *g*) a problem :sign0085:

I am currently trying to use the great door-library to raise some events when I click into a, for this example, textbox.

This is the code which works perfectly all right on the desktop:
B4X:
Sub App_Start
...
objectHotSpotFillLevelClick.New1(False)
objectHotSpotFillLevelClick.FromControl("textBoxFillLevel")
eventHotSpotFillLevelClick.New1(objectHotSpotFillLevelClick.value,"MouseClick")
...
End Sub

Sub eventHotSpotFillLevelClick_NewEvent
   objectHotSpotFillLevelClick.value = eventHotSpotFillLevelClick.Data
   x = objectHotSpotFillLevelClick.GetProperty("X")
   y = objectHotSpotFillLevelClick.GetProperty("Y")
   CallSub ("doHotSpotCheck", "fillLevel", x, y)
End Sub

So that works perfectly on the desktop... I click into the textBox and
my Sub "doHotSpotCheck" gets called and displays an AlertBox.

BUT here comes the problem:
On the device I get directly when I start my app an error:
"An error occured on sub _main_app_start.
NullReferenceException
Continue?"

Ok then I thought the "MouseClick" might be the problem, so I changed it to:
B4X:
objectHotSpotFillLevelClick.New1(False)
objectHotSpotFillLevelClick.FromControl("textBoxFillLevel")
eventHotSpotFillLevelClick.New1(objectHotSpotFillLevelClick.value,"TextChanged")

Now the program starts and when I change the text in the textbox, I get
this (same) error:
"An error occured on sub _main_eventhotspotfilllevelclick_newevent.
NullReferenceException
Continue?"

The problem seems to be this command
"objectHotSpotFillLevelClick.GetProperty("X")", as when I comment it out
I get no error (of course I also commented out the second line where this command occurs for the "Y"-value).

So I would really be very happy if anybody could help me:
- why do I get this error when I have "MouseClick" enabled?
- why do I still get an error when I jump into the event?

As I said before that all works perfectly well on the desktop! :sign0085:

Thanks a lot in advance for any help :)

Best regards,

Chris
 

agraham

Expert
Licensed User
Longtime User
why do I get this error when I have "MouseClick" enabled?
The device does not support any mouse events on a Textbox. Look at the event list here TextBox Members (System.Windows.Forms). A little device icon denotes what is available in the Compact Framework.
why do I still get an error when I jump into the event?
It's a different error. Event objects don't have X and Y properties, they only have a Data property that contains the EventArgs of the event. Look at the last example in the Door library help Overview topic. Different events have different EventArgs, you need to know what properties a particular EventArgs supports.
 

CryoGenID

Active Member
Licensed User
Longtime User
Thanks a lot for your reply!

I have just looked at the link you gave me, thanks for that as well!
But I am having trouble finding the "Image" Class there...

My final goal is to be able to catch the "click"-Event on an image (perfect if I would also get the XY-Coordinates where the Image was clicked)...
Or is there a workaround/trick to get that functionality to catch a click on an image?

Thanks a lot in advance!

Best regards,

Chris
 

CryoGenID

Active Member
Licensed User
Longtime User
agraham,

perfect thanks a lot :)
It is working now, just had to change "MouseClick" to "Click" ;-)

Just one last question: Where exactly can I get the list of the properties
which I could get with this command (for each class e.g. Image, textBox, etc.):
objectHotSpotFillLevelClick.GetProperty() ?

Thanks a lot again!

Best regards,

Chris
 

agraham

Expert
Licensed User
Longtime User
objectHotSpotFillLevelClick.GetProperty() ?
This is not a valid statement. Didn't you read the help I mentioned earlier? That is an example of accessing the mouse button from a MouseEventArgs returned by an event. To know what properties an EventArgs contains you need to look at the EventHandler for the event, which you can find by clicking on the event in the list of events. The type of EventHandler determines the type of the EventArgs so you need to find that in the documention.

If you want the X,Y coordinates the Click event doesn't return them as it returns a standard EventArgs. Use MouseDown which returns a MouseEventArgs that has X and Y properties that you can read. MouseEventArgs Class (System.Windows.Forms)
 

CryoGenID

Active Member
Licensed User
Longtime User
Agraham,

thanks for your reply.
Yes sure I read the documentation. My question was basically where exactly I could get the information about which EventArgs/MouseEventArgs are available for which control and which Information is provided with which EventArg-Type...

Thanks a lot for your help, that has clarified a lot!

Best regards,

Chris
 

CryoGenID

Active Member
Licensed User
Longtime User
Klaus,

thanks a lot!
There is such a lot of great and valuable information/utils here, it is really hard to keep track of all that ;-)

Will that also work on the device and only show the events available for the device?

Thanks again,

best regards,

Chris
 

klaus

Expert
Licensed User
Longtime User
The program is more general, not only for the device.
I haven't tested it on the device, but it should work.
There is a direct link to Microsofts MSDN Internet site. There you have all detailed information and you will see if the property, event or method is available for the PPC's.

Best regards.
 
Top