Mark Read Well-Known Member Licensed User Longtime User Mar 14, 2016 #1 This is a small project I am working on to create .Desktop files for the RPi. I have the option to load a file already created, modify and save to a new name. My problem is when I load a file, there are two Mime Type ComboBoxes which should be set. The first one works, the second not. Can anyone see where I have made a mistake? The files are saved in "Objects-home-pi-Desktop". A sample file is included "MyDesktop.Desktop" Many thanks. Attachments Desktop.zip Desktop.zip 68.5 KB · Views: 533
This is a small project I am working on to create .Desktop files for the RPi. I have the option to load a file already created, modify and save to a new name. My problem is when I load a file, there are two Mime Type ComboBoxes which should be set. The first one works, the second not. Can anyone see where I have made a mistake? The files are saved in "Objects-home-pi-Desktop". A sample file is included "MyDesktop.Desktop" Many thanks.
R rboeck Well-Known Member Licensed User Longtime User Mar 14, 2016 #2 Hi to leoben, your mistake is only the length of the strings - i made the following change: Code: Copy 347 Dim res As String=result(0) & " - " & result(1) 348 If res.Length>60 Then res=res.SubString2(0,60) 349 cbMime2.Items.Add(res) The strange thing: even if i use cbMime2.Items.Add(result(0) & " - " & result(1)) like your version alreay was, it works. Dont ask me why... (Maybe its a side effect of : 'can cause odd things if no value after ') Greetings from L.A. ( lower austria) Last edited: Mar 14, 2016 Upvote 0
Hi to leoben, your mistake is only the length of the strings - i made the following change: Code: Copy 347 Dim res As String=result(0) & " - " & result(1) 348 If res.Length>60 Then res=res.SubString2(0,60) 349 cbMime2.Items.Add(res) The strange thing: even if i use cbMime2.Items.Add(result(0) & " - " & result(1)) like your version alreay was, it works. Dont ask me why... (Maybe its a side effect of : 'can cause odd things if no value after ') Greetings from L.A. ( lower austria)
Mark Read Well-Known Member Licensed User Longtime User Mar 14, 2016 #3 rboeck said: your mistake is only the length of the strings - i made the following change: Click to expand... Tried your changes and still no luck. Still using my original post. It would seem that after loading and setting all the fields, the data changed event is called for each view. For cbMime1, this is required, as it then populates cbMime2 with the correct data. But then in cbMime2, the correct value is shown but is then erased. I do not understand why, Stepping through in debug mode shows everything to be correct. At a loss! Upvote 0
rboeck said: your mistake is only the length of the strings - i made the following change: Click to expand... Tried your changes and still no luck. Still using my original post. It would seem that after loading and setting all the fields, the data changed event is called for each view. For cbMime1, this is required, as it then populates cbMime2 with the correct data. But then in cbMime2, the correct value is shown but is then erased. I do not understand why, Stepping through in debug mode shows everything to be correct. At a loss!
R rboeck Well-Known Member Licensed User Longtime User Mar 14, 2016 #4 I tried it now in release mode, but now i don't see the problem. With the original code from you, the text information for cmMime2 was placed on the whole width of the app and not inside the combobox. With my correction i select one mime type in cbMime1 and cbMime2 seems to get filled without problems. What exactly is wrong here? Upvote 0
I tried it now in release mode, but now i don't see the problem. With the original code from you, the text information for cmMime2 was placed on the whole width of the app and not inside the combobox. With my correction i select one mime type in cbMime1 and cbMime2 seems to get filled without problems. What exactly is wrong here?
Mark Read Well-Known Member Licensed User Longtime User Mar 14, 2016 #5 rboeck said: With my correction i select one mime type in cbMime1 and cbMime2 seems to get filled without problems. What exactly is wrong here? Click to expand... The problem is not when you create a new file. If you load an existing file (included MyDesktop.Desktop), the cbMime1 loads correctly but cbMime2 not and I cannot see why. Upvote 0
rboeck said: With my correction i select one mime type in cbMime1 and cbMime2 seems to get filled without problems. What exactly is wrong here? Click to expand... The problem is not when you create a new file. If you load an existing file (included MyDesktop.Desktop), the cbMime1 loads correctly but cbMime2 not and I cannot see why.
R rboeck Well-Known Member Licensed User Longtime User Mar 14, 2016 #6 My pi is currently not connected, i copied the two files from home to an usb stick, used b4j only on pc an it seems ok. Mime Type ist application, cbMime2 if filled with more then fifty items. Upvote 0
My pi is currently not connected, i copied the two files from home to an usb stick, used b4j only on pc an it seems ok. Mime Type ist application, cbMime2 if filled with more then fifty items.
rwblinn Well-Known Member Licensed User Longtime User Mar 14, 2016 #7 Hi Mark, pls check if attached is working. Have made some changes, like defining subs to handle comboboxes population, stringutils library to load csv, matcher to compare. Attachments Desktop Generator.zip Desktop Generator.zip 68 KB · Views: 539 Upvote 0
Hi Mark, pls check if attached is working. Have made some changes, like defining subs to handle comboboxes population, stringutils library to load csv, matcher to compare.
Mark Read Well-Known Member Licensed User Longtime User Mar 15, 2016 #8 @rwblinn, sorry I am using b4j 3.71 and I cannot run your version. Any way I will try and explain exactly what the problem is. I have made slight changes in the app as the Mime was incorrect. Take the attached zip file as the new app version. Copy the MyDesktop.txt to a known directory and rename to MyDesktop.Desktop Set a breakpoint on line 358 Run in debug mode Click "Load File" and select the MyDesktop.Desktop file you have saved somewhere. The app will now stop at line 358 "cbMime2_SelectedIndexChanged", Index=1 and Value=3gpp and in the UI the value 3gpp is visible - great. Step through the subroutine After "End Sub" the value in the UI is gone! This is what I don't understand, I have not done anything. Even worse, the sub then runs a second time?????? This has got to be something simple but it is driving me nuts. rboeck said: My pi is currently not connected Click to expand... Sorry, my original plan was to use this app on my RPi but the filechooser does not work, therefore it only works in windows. Attachments Desktop.zip Desktop.zip 31.2 KB · Views: 548 MyDesktop.txt MyDesktop.txt 225 bytes · Views: 566 Upvote 0
@rwblinn, sorry I am using b4j 3.71 and I cannot run your version. Any way I will try and explain exactly what the problem is. I have made slight changes in the app as the Mime was incorrect. Take the attached zip file as the new app version. Copy the MyDesktop.txt to a known directory and rename to MyDesktop.Desktop Set a breakpoint on line 358 Run in debug mode Click "Load File" and select the MyDesktop.Desktop file you have saved somewhere. The app will now stop at line 358 "cbMime2_SelectedIndexChanged", Index=1 and Value=3gpp and in the UI the value 3gpp is visible - great. Step through the subroutine After "End Sub" the value in the UI is gone! This is what I don't understand, I have not done anything. Even worse, the sub then runs a second time?????? This has got to be something simple but it is driving me nuts. rboeck said: My pi is currently not connected Click to expand... Sorry, my original plan was to use this app on my RPi but the filechooser does not work, therefore it only works in windows.
R rboeck Well-Known Member Licensed User Longtime User Mar 15, 2016 #9 Hi, i also tried to find the problem: i think, you are calling cbMime1_SelectedIndexChange.. in line 161 and the system itself does it also. So you get the cbMime2 filling two times and all the side effects. I have tried to remark line 161 and the second filling is gone; but i am not able to look further, if all other functions are working. Upvote 0
Hi, i also tried to find the problem: i think, you are calling cbMime1_SelectedIndexChange.. in line 161 and the system itself does it also. So you get the cbMime2 filling two times and all the side effects. I have tried to remark line 161 and the second filling is gone; but i am not able to look further, if all other functions are working.
Mark Read Well-Known Member Licensed User Longtime User Mar 15, 2016 #10 rboeck said: i think, you are calling cbMime1_SelectedIndexChange.. in line 161 Click to expand... You are correct. The cbMime1 is filled upon starting the app. CbMime2 is filled according to the section made in cbMime1, that means at start, there are no values present. Upvote 0
rboeck said: i think, you are calling cbMime1_SelectedIndexChange.. in line 161 Click to expand... You are correct. The cbMime1 is filled upon starting the app. CbMime2 is filled according to the section made in cbMime1, that means at start, there are no values present.
Mark Read Well-Known Member Licensed User Longtime User Mar 15, 2016 #11 Found a solution but still don't know why it works. changed: Code: Copy Sub cbMime2_SelectedIndexChanged(Index As Int, Value As Object) If Index=-1 Then Return Mime2=Value DataHasChanged=True End Sub to: Code: Copy Sub cbMime2_SelectedIndexChanged(Index As Int, Value As Object) If Index=-1 Then Return cbMime2.SelectedIndex = Index Mime2=Value DataHasChanged=True End Sub Many thanks to all for the help. Upvote 0
Found a solution but still don't know why it works. changed: Code: Copy Sub cbMime2_SelectedIndexChanged(Index As Int, Value As Object) If Index=-1 Then Return Mime2=Value DataHasChanged=True End Sub to: Code: Copy Sub cbMime2_SelectedIndexChanged(Index As Int, Value As Object) If Index=-1 Then Return cbMime2.SelectedIndex = Index Mime2=Value DataHasChanged=True End Sub Many thanks to all for the help.