Detecting a MuiCycle event and its selected option - Druckversion +- AmiBlitz³ (https://www.amiblitz.de/community) +-- Forum: AmiBlitz³ (https://www.amiblitz.de/community/forum-3.html) +--- Forum: Questions & Answers (https://www.amiblitz.de/community/forum-7.html) +--- Thema: Detecting a MuiCycle event and its selected option (/thread-147.html) Seiten:
1
2
|
Detecting a MuiCycle event and its selected option - AlfaRomeo - 12.08.2015 Hi guys, could someone give me an example code in AmiBlitz on how to detect that a MuiCycle gadget was pressed and which MuiCycle option was selected, please? There are very few examples about using AmiBlitz in conjunction with MUI on the internet and I didn´t found one about MUICycle within AmiBlitz Re: Detecting a MuiCycle event and its selected option - Der Wanderer - 12.08.2015 You should look this up in the MUI documentation. This is not AmiBlitz specific. If you can post it in C code, I can easily point you out the Amiblitz code. Re: Detecting a MuiCycle event and its selected option - AlfaRomeo - 12.08.2015 Ok, thanks Re: Detecting a MuiCycle event and its selected option - Der Wanderer - 12.08.2015 Hm.. but I remember darkly that there was an issue with the MuiCycle. This has come up several times. Don't remember what the solution was. Maybe you need to work your way around with the MUI*_ functions. All functions with "_" at the end map directly to the library functions. So you can port 1:1 the code you would see in C. BlitzBasic functions without underscore may have some convenient code around it, that makes it easier but often introduces limitations or bugs. Same with GadTools. If you need 100% access to GadTools, you will need the library functions directly. Re: Detecting a MuiCycle event and its selected option - Daedalus - 12.08.2015 I have some code that works around a couple of issues with MUICycle, I'll dig it out when I get a chance. It is possible, but I ended up calling the class directly using MUINewObject and setting it up that way. Notifications are handled like any other gadget, MUINotifyApp works fine here. And to get the current item I used MUIGet and the relevant tags instead of the MUICycle commands. Again, I'll post some code when I have a chance, just not near my Amiga at the moment... Edit: As an aside, I'm working on updating the AmiBlitz section of amigacoding.com, and will add a section on using MUI there as a few people (including myself) have looked for examples like that. Re: Detecting a MuiCycle event and its selected option - AlfaRomeo - 13.08.2015 Hi Daedalus, thanks for reply. I already tried some code around "MUIGetCycle" and "MUINotify...#MUIA_Cycle_Active" but had no success in detecting the MUICycle pressed and then getting the option selected and also there are no snippets about it in AmiBlitz so I almost give it up because I have not much time. Daedalus schrieb:I'll post some code when I have a chance, just not near my Amiga at the moment... I will apreciate it, thanks in advance 8-) Daedalus schrieb:I'm working on updating the AmiBlitz section of amigacoding.com, and will add a section on using MUI there as a few people (including myself) have looked for examples like that. I´m sure that will be much usefull to many people because there are very few examples of AmiBlitz and MUI around... Re: Detecting a MuiCycle event and its selected option - Daedalus - 15.08.2015 Okay, I've had a look through my code, and using the built-in commands works fine for the cycle gadget, provided it doesn't have too many entries. It appears that there is a fixed amount of space allocated by the MUICycle command, and adding too many options causes trashed memory and usually a crash. I don't know what that number is or if it changes based on length of entries or what, but for up to 10 entries it should be safe and this code works fine for me: Code: WBStartup For more entries, you need to call the muicycle custom class directly, and that's a little bit more complicated. I use this code instead of MUICycle for longer lists of options: Code: MUINewObject #main_cycle,"Cycle.mui",#MUIA_Cycle_Entries,&*cycleoptionaddrs(0) Code: For i=0 To #maxoptions-1 Setting up a notify is no problem, similar to any other gadget but using the cycle gadget specific constant #MUIA_Cycle_Active which you set up to trigger every time the active entry changes. MUINotifyApp works fine here. Finally, reading the active entry seems to work fine for me with MUIGetCycle, but it can also be read by using: Code: result=MUIGet(#main_cycle,#MUIA_Cycle_Active) Code: MUISet #main_cycle,#MUIA_Cycle_Active,entry Code: MUISet #main_cycle,#MUIA_NoNotify,1,#MUIA_Cycle_Active,entry The MUI Autodocs contain descriptions of al lthe constants that apply for each object type. They're quite well laid out and while the code will look a little different to the C examples, the basics are the same, and the constants are the same too except they have a # in front of the name in Blitz but not in C. General rule for the MUI constants, those starting with #MUIA_ are attributes, #MUIM_ are methods, #MUIV_ are special values specific to the objects in question, and #MUII_ are MUI images. Hope that helps! Re: Detecting a MuiCycle event and its selected option - AlfaRomeo - 16.08.2015 Hi Daedalus, Many thanks for your effort in giving me this detailed information with the examples, later I will analyse your examples so I can see if they help me solving my code problem. Daedalus schrieb:For more entries, you need to call the muicycle custom class directly, and that's a little bit more complicated. I only need 4 entries in each of 2 cycle gadgets I will need, so no problem with that. Daedalus schrieb:Setting up a notify is no problem, similar to any other gadget but using the cycle gadget specific constant #MUIA_Cycle_Active which you set up to trigger every time the active entry changes. MUINotifyApp works fine here. Setting up the notify is my problem, I had tried various forms of coding the notify (all with MUINotify instead of MUINotifyApp) but with no luck. The one I choosed was: Code: MUINotify 2,#MUIA_Cycle_Active,#MUIV_EveryTime,2,#MUIM_Set,MyChoice Next I post the code I created so could test the 2 cycle gadgets, if you run it will see that all works well but it never gives the selection in the 2nd cycle gadget: Code: WBStartup Daedalus schrieb:Hope that helps! It will help for sure, again, thanks for your effort. Re: Detecting a MuiCycle event and its selected option - Daedalus - 16.08.2015 Okay, there are some strange things with your program for me. First off is that MUIWaitEvent is a little bit broken, and program flow continues even if no event has occurred. I don't know why that is but I suspect a bug in the MUI library that makes it behave identically to MUIEvent. This means that the loop runs constantly, which it should not. This in itself still isn't a real problem, except that you're checking the event code for the value of MyChoice, but that's always going to be zero as well. MyChoice2 is also going to be zero, but once one Case of a Select is triggered, all the other Cases are ignored. Because the event is triggered constantly with a 0, and MyChoice is also 0, it's always the first entry that triggers. That works correctly though, displaying the value of the entry in the first cycle gadget. It means that the code for reading the second cycle gadget should work but never gets to run. You'll notice that the value is displayed even when the notifies for the cycle gadgets are commented out. Again, this is because your loop is running constantly and always triggering the first Case with 0 = 0. I'm not sure exactly what you were trying to do with the notifies, but the MUISet method requires two arguments following it: the attribute to set and the value to set it to. It doesn't set a variable contents, and you need to use a special #MUIV_ constant to set an attribute to the value of another gadget. That would be used for automatically setting a string gadget to the value of a slider for example, but can't be used for setting variables. so those notifies are effectively doing nothing (and maybe writing garbage to memory in some cases so be careful...) What you need to do is first set up your loop so it only responds to event codes other than zero, then you need to either use MUINotifyApp to send the events to the application, or use MUINotify with the application object as a target (which is just what MUINotifyApp does anyway). So swap this code for the second part of your program and see the difference: Code: MUINotifyApp 11,#MUIA_Window_CloseRequest,1,-11 Re: Detecting a MuiCycle event and its selected option - AlfaRomeo - 18.08.2015 Hi Daedalus, You´re right, everything you wrote is correct. This is the first time I used MUI and I want to make an application that uses 2 cycle gadgets, so I wanted to understand how cycle gadgets are detected by the code but I never got do the Notify works as it should. This is because I always used the MUINotify instead of MUINotifyApp. My app is at the begining of coding (I was only testing how MUI works) and I was stuck with the Notify but, with your help, I reached my goal and now the code works well: Code: WBStartup |