sterlingy Active Member Licensed User Longtime User May 15, 2012 #1 I have a panel made in the designer. Attached to it are 9 ImageViews In my code, I have subroutine the detects a click on one of the ImageViews. This works. But determining which ImageView is clicked results in an error, "Class Exception," and I don't know why: Code: Sub pnlCameraEffect_Click Dim cameraEffectChoice As ImageView cameraEffectChoice = Sender Select cameraEffectChoice.Tag Case "0" camera1.ColourEffect = "NONE" pnlCameraEffect.Visible = False Case "1" camera1.ColourEffect = "AQUA" pnlCameraEffect.Visible = False Case "2" camera1.ColourEffect = "BLACKBOARD" pnlCameraEffect.Visible = False Case "3" camera1.ColourEffect = "MONO" pnlCameraEffect.Visible = False Case "4" camera1.ColourEffect = "NEGITIVE" pnlCameraEffect.Visible = False Case "5" camera1.ColourEffect = "POSTERIZE" pnlCameraEffect.Visible = False Case "6" camera1.ColourEffect = "SEPIA" pnlCameraEffect.Visible = False Case "7" camera1.ColourEffect = "SOLARIZE" pnlCameraEffect.Visible = False Case "8" camera1.ColourEffect = "WHITEBOARD" pnlCameraEffect.Visible = False End Select End Sub
I have a panel made in the designer. Attached to it are 9 ImageViews In my code, I have subroutine the detects a click on one of the ImageViews. This works. But determining which ImageView is clicked results in an error, "Class Exception," and I don't know why: Code: Sub pnlCameraEffect_Click Dim cameraEffectChoice As ImageView cameraEffectChoice = Sender Select cameraEffectChoice.Tag Case "0" camera1.ColourEffect = "NONE" pnlCameraEffect.Visible = False Case "1" camera1.ColourEffect = "AQUA" pnlCameraEffect.Visible = False Case "2" camera1.ColourEffect = "BLACKBOARD" pnlCameraEffect.Visible = False Case "3" camera1.ColourEffect = "MONO" pnlCameraEffect.Visible = False Case "4" camera1.ColourEffect = "NEGITIVE" pnlCameraEffect.Visible = False Case "5" camera1.ColourEffect = "POSTERIZE" pnlCameraEffect.Visible = False Case "6" camera1.ColourEffect = "SEPIA" pnlCameraEffect.Visible = False Case "7" camera1.ColourEffect = "SOLARIZE" pnlCameraEffect.Visible = False Case "8" camera1.ColourEffect = "WHITEBOARD" pnlCameraEffect.Visible = False End Select End Sub
klaus Expert Licensed User Longtime User May 15, 2012 #2 In what line do you get the error and what is the exact message. It would be much easier to help you if you posted your project as a zip file (IDE menu Files / Export As Zip). Best regards. Upvote 0
In what line do you get the error and what is the exact message. It would be much easier to help you if you posted your project as a zip file (IDE menu Files / Export As Zip). Best regards.
sterlingy Active Member Licensed User Longtime User May 15, 2012 #3 Hi Klaus, I can't post the project without spending a lot of time hiding Server information and passwords. The code stops at "cameraEffectChoice = Sender" I should correct my previous message, the error says: "ClassCastException" -Sterling Upvote 0
Hi Klaus, I can't post the project without spending a lot of time hiding Server information and passwords. The code stops at "cameraEffectChoice = Sender" I should correct my previous message, the error says: "ClassCastException" -Sterling
Woinowski Active Member Licensed User Longtime User May 15, 2012 #4 Guess: Click comes from Panel Hi, your method is called pnlCameraEffect_Click. Could it be that the click event is not raised by the ImageViews, but by the panel they contain? To check this, add this code at the beginning of the method: try Dim p as Panel p = Panel MessBox("It's a panel", "That's it") return catch MasgBox(LastException.Message, "Not a panel") end try If you get "It's a panel" then you need to wire the panel to a different event. Upvote 0
Guess: Click comes from Panel Hi, your method is called pnlCameraEffect_Click. Could it be that the click event is not raised by the ImageViews, but by the panel they contain? To check this, add this code at the beginning of the method: try Dim p as Panel p = Panel MessBox("It's a panel", "That's it") return catch MasgBox(LastException.Message, "Not a panel") end try If you get "It's a panel" then you need to wire the panel to a different event.
sterlingy Active Member Licensed User Longtime User May 15, 2012 #5 Here's the actual error message from the debugger: java.lang.ClassCastException: anywheresoftware.b4a.BALayout -Sterling Upvote 0
Here's the actual error message from the debugger: java.lang.ClassCastException: anywheresoftware.b4a.BALayout -Sterling
sterlingy Active Member Licensed User Longtime User May 15, 2012 #6 Woinowski said: try Dim p as Panel p = Panel MessBox("It's a panel", "That's it") return catch MasgBox(LastException.Message, "Not a panel") end try Click to expand... I dropped your code into mine, but is has errors Code: p = Panel Error description: Undeclared variable 'panel' is used before it was assigned any value. -Sterling Upvote 0
Woinowski said: try Dim p as Panel p = Panel MessBox("It's a panel", "That's it") return catch MasgBox(LastException.Message, "Not a panel") end try Click to expand... I dropped your code into mine, but is has errors Code: p = Panel Error description: Undeclared variable 'panel' is used before it was assigned any value. -Sterling
boten Active Member Licensed User Longtime User May 15, 2012 #7 Just a guess (same idea as Woinowski): from the name of the event, it might be that this is an event for the panel click (and NOT for the imageview click), hence the sender is a panel and you try to assign it to an imageview. Upvote 0
Just a guess (same idea as Woinowski): from the name of the event, it might be that this is an event for the panel click (and NOT for the imageview click), hence the sender is a panel and you try to assign it to an imageview.
sterlingy Active Member Licensed User Longtime User May 15, 2012 #9 Thanks to all who chimed in. The problem was tat the ImageViews needed to be part of the same EVENT. The moral of the story is don't code near midnight! -Sterling :sign0161: Upvote 0
Thanks to all who chimed in. The problem was tat the ImageViews needed to be part of the same EVENT. The moral of the story is don't code near midnight! -Sterling :sign0161:
Woinowski Active Member Licensed User Longtime User May 15, 2012 #10 sterlingy said: I dropped your code into mine, but is has errors Code: p = Panel Error description: Undeclared variable 'panel' is used before it was assigned any value. -Sterling Click to expand... That was a typo: p = Sender Upvote 0
sterlingy said: I dropped your code into mine, but is has errors Code: p = Panel Error description: Undeclared variable 'panel' is used before it was assigned any value. -Sterling Click to expand... That was a typo: p = Sender