Page 1 of 2

PopUp Menus

Posted: Mon Dec 30, 2019 7:45 pm
by deanathpc
Alright so I seem to have an ongoing issue with my popup menus. They seem to be affecting my main Menubar. For example when I click on File: Save As it seems to trigger one of my Popup menu events instead. When I disable my popup menus all seems o.k. So I am guessing it's an enumeration issue?

I use PureVision for my GUI creation. So I have to include that file obviously. I used to use PureForm but for some reason that keeps closing down or worse yet keeps changing windows while trying edit so I switched to PureVision.

Code: Select all

UseSQLiteDatabase()

UseJPEGImageDecoder()
UseTGAImageDecoder()
UsePNGImageDecoder()
UseTIFFImageDecoder()
UseGIFImageDecoder()


Enumeration
    #MyPopUpMenu
  #PopupMenu_ViewEdit
  #PopupMenu_Delete
  #PopupMenu_Duplicate
  #PopupMenu_Cancel
  
  #MyPopUpMenu1
  #PopupMenu1_ViewEdit
  #PopupMenu1_Cancel
  
  #MyPopUpMenu2
  #PopupMenu2_ViewEdit
  #PopupMenu2_Cancel
EndEnumeration

; Pure PDF Stuff
#PurePDF_Include=1
XIncludeFile "PurePDF.pb"
Declare Header()
Declare Footer()
Declare ReportTitleClear()

Global DBFullName.s, DBName.s, DBProgramName$, DBVersion$, DBVersionC$, DBFullName$
Global DataListEdit$, NewRecord_DataItem, DataItemPullResult, ModifyResult, ItemModify, REGISTERFLAG, PhotoDocsModifyResult, PictureDocPullResult
Global WebsiteButtonChosen$, Website_ModifyResult
Global PrefName$, PrefEMail$, PrefRegistrationCode$, PrefLastUsed$
Global ImageFilename.s = "", pictureSize, *picture, GlobalImageName$
Global ReportTitle$, ReportTitleOther$

;- XIncludes
XIncludeFile "ListIconGadgetInclude.pbi"

;XIncludeFile "firearms-gui2.pbf"
;XIncludeFile "firearms-dataprogress.pbf"
;XIncludeFile "firearms-datalistgui.pbf"

XIncludeFile "Firearms-GUI3_Windows.pb"

XIncludeFile "firearms-datalistediting.pb"
XIncludeFile "firearms-firearms.pb"
XIncludeFile "firearms-ammunition.pb"
XIncludeFile "firearms-accessories.pb"
XIncludeFile "firearms-maintenance.pb"
XIncludeFile "firearms-scoring.pb"
XIncludeFile "firearms-reloading.pb"
XIncludeFile "firearms-reloadingrecipes.pb"
XIncludeFile "firearms-setup.pb"

Declare AutocompleteComboBox(ComboBox.l)
Declare UnMangle(regname$, code$)
Declare OpenDB()
Declare CreateTable()
Declare HelpScreen()
Declare HelpScreen_Specifics()
Declare AboutScreen()
Declare Toolbar_Active(selectedtoolbar$)
Declare ViewDocumentsSaved()
Declare NewDatabase()
Declare OpenExistingDatabase()
Declare SaveAsDatabase()

;-Program Name and Version
DBProgramName$ = "Firearms Inventory"
DBVersion$ = " v 0.72.0b" ;- Version Number
DBVersionC$ = " v " + #PB_Editor_CreateExecutable + "." + #PB_Editor_BuildCount + "." + #PB_Editor_CompileCount

DataSection
  PopulatedFlag:
  IncludeBinary "Images\lightbulb.ico"
  NonPopulatedFlag:
  IncludeBinary "Images\lightbulb-off.ico"
EndDataSection

Window_Form1()
;SetWindowTitle(#Window_Form1, DBProgramName$ + DBVersion$)

;-Create Popup Menus
If CreatePopupMenu(#MyPopUpMenu)
  MenuItem(#PopupMenu_ViewEdit, "View/Edit")
  MenuItem(#PopupMenu_Delete, "Delete")
  MenuItem(#PopupMenu_Duplicate, "Duplicate")
  MenuBar()
  MenuItem(#PopupMenu_Cancel, "Cancel")
EndIf
;
; ;For Firearms Accessories ListIcon
If CreatePopupMenu(#MyPopUpMenu1)
  MenuItem(#PopupMenu1_ViewEdit, "View/Edit")
  MenuBar()
  MenuItem(#PopupMenu1_Cancel, "Cancel")
EndIf
;
; ;For Firearms Maintenance ListIcon
If CreatePopupMenu(#MyPopUpMenu2)
  MenuItem(#PopupMenu2_ViewEdit, "View/Edit")
  MenuBar()
  MenuItem(#PopupMenu2_Cancel, "Cancel")
EndIf
This is the start of things. If I relocated the Enumeration section other things get messed up. If I change the location of the CreatePopupMenu section some things screw up. I have seen the examples. People usually use a number where my #MyPopUpMenu1 is located etc. I've tried that. That is how I started. That really messed things up. So I am at a loss how to make things work here.

So currently when I click on File: Save As in my Menubar it triggers the MenuItem(#PopupMenu_Cancel, "Cancel") event. I have no idea why. And if I click on Edit:Settings it also triggers a PopupMenu event. I just don't get it. I'm about to get rid of the Popup menus and figure out something else.

File:Open will act as those the Popup Menu : Duplicate has been selected. Just odd behavior.

But yet my File:Exit will in fact exit the program.

And it would appear that my Popup Menus do in fact work correctly where they were meant to. Just the MenuBar that is screwing up.

What other code do you need to see to better understand? Or what other information might you need to help better understand? I'm sure I have not explained it correctly or with enough detail to help to understand my issue.

Updated with the correct code.

Re: PopUp Menus

Posted: Mon Dec 30, 2019 8:53 pm
by mk-soft
I don't see any enumerations for menu items, etc... but I thing is an Enumeration problem

But you can use named enumeration and change the start value of enumerations.

Code: Select all

; First part or file
Enumeration popup_menuitems 1001
  #PopupMenu_ViewEdit
  #PopupMenu_Delete
  #PopupMenu_Duplicate
  ; ...
EndEnumeration

; Next part or file
Enumeration popup_menuitems
  #PopupMenu1_ViewEdit
  #PopupMenu1_Cancel
  ; ...
EndEnumeration

Debug #PopupMenu_ViewEdit
Debug #PopupMenu_Delete
Debug #PopupMenu_Duplicate

Debug #PopupMenu1_ViewEdit
Debug #PopupMenu1_Cancel

Re: PopUp Menus

Posted: Mon Dec 30, 2019 10:38 pm
by deanathpc
mk-soft wrote:I don't see any enumerations for menu items, etc... but I thing is an Enumeration problem

But you can use named enumeration and change the start value of enumerations.

Code: Select all

; First part or file
Enumeration popup_menuitems 1001
  #PopupMenu_ViewEdit
  #PopupMenu_Delete
  #PopupMenu_Duplicate
  ; ...
EndEnumeration

; Next part or file
Enumeration popup_menuitems
  #PopupMenu1_ViewEdit
  #PopupMenu1_Cancel
  ; ...
EndEnumeration

Debug #PopupMenu_ViewEdit
Debug #PopupMenu_Delete
Debug #PopupMenu_Duplicate

Debug #PopupMenu1_ViewEdit
Debug #PopupMenu1_Cancel
That is because my enumeration section didnt paste correctly. I will try to paste it correctly here a little later.

Sorry... I did paste it in initially.

That might change your response.

Sent from my SM-G955U using Tapatalk

Re: PopUp Menus

Posted: Mon Dec 30, 2019 10:47 pm
by deanathpc
mk-soft wrote:I don't see any enumerations for menu items, etc... but I thing is an Enumeration problem

But you can use named enumeration and change the start value of enumerations.

O.K. Pasted the code in correctly now. I'm sorry about that.

Re: PopUp Menus

Posted: Mon Dec 30, 2019 10:59 pm
by mk-soft
If PureVision also creates menus with constants, your MenuItems will conflict with them.

So your enumeration for the MenuItems must start with a different higher value.

Re: PopUp Menus

Posted: Mon Dec 30, 2019 11:21 pm
by deanathpc
mk-soft wrote:If PureVision also creates menus with constants, your MenuItems will conflict with them.

So your enumeration for the MenuItems must start with a different higher value.
Hmmm the menus do have enumeration. I believe they start out... Enumeration 1. But I've seen that a few times.

So I need to figure out how Pure Vision leaves off for the menus then? What the next number would be?

I know at one point I used #PB_Any and it told me the number was too high! Lol

Sent from my SM-G955U using Tapatalk

Re: PopUp Menus

Posted: Tue Dec 31, 2019 1:49 am
by mk-soft
Just start with enumeration 1000 for the popup MenuItems.
I think you will not create more than 1000 standard MenuItems with PureVision. :wink:

Re: PopUp Menus

Posted: Tue Dec 31, 2019 2:18 am
by deanathpc
mk-soft wrote:Just start with enumeration 1000 for the popup MenuItems.
I think you will not create more than 1000 standard MenuItems with PureVision. :wink:
Ok. I'll try it like you have it and see how that goes. Thank you

Sent from my SM-G955U using Tapatalk

Re: PopUp Menus

Posted: Tue Dec 31, 2019 4:57 am
by Fangbeast

Code: Select all

;- Window Constants

Enumeration 1
  #Window_Myfamily
EndEnumeration

#WindowIndex = #PB_Compiler_EnumerationValue

;- Gadget Constants

Enumeration 1
  ;Window_Myfamily
  #MenuBar_Myfamily_FileMenu
EndEnumeration

#GadgetIndex = #PB_Compiler_EnumerationValue

;- MenuBar Constants

Enumeration 1
  #MenuBar_Myfamily
EndEnumeration

#MenuBarIndex = #PB_Compiler_EnumerationValue

;- Image Constants

Enumeration 1
  #MenuBarIcon_Myfamily_BackupDatabase
  #Image_Myfamily_Kill
EndEnumeration

#ImageIndex  =  #PB_Compiler_EnumerationValue
Purevision does the above. Note that it ends each enumeration with the current state such as

Code: Select all

#WindowIndex = #PB_Compiler_EnumerationValue
for the windows value.

So if you have more of your own window enumerations, just start your section off with:

Code: Select all

Enumeration #WindowIndex 
and the window enumeration will be then correct.

Re: PopUp Menus

Posted: Tue Dec 31, 2019 5:30 am
by deanathpc
mk-soft wrote:Just start with enumeration 1000 for the popup MenuItems.
I think you will not create more than 1000 standard MenuItems with PureVision. :wink:
I had to add a little more but I got it working!!!! Thank you!

Sent from my SM-G955U using Tapatalk

Re: PopUp Menus

Posted: Tue Dec 31, 2019 5:31 am
by deanathpc
Fangbeast wrote:

Code: Select all

;- Window Constants

Enumeration 1
  #Window_Myfamily
EndEnumeration

#WindowIndex = #PB_Compiler_EnumerationValue

;- Gadget Constants

Enumeration 1
  ;Window_Myfamily
  #MenuBar_Myfamily_FileMenu
EndEnumeration

#GadgetIndex = #PB_Compiler_EnumerationValue

;- MenuBar Constants

Enumeration 1
  #MenuBar_Myfamily
EndEnumeration

#MenuBarIndex = #PB_Compiler_EnumerationValue

;- Image Constants

Enumeration 1
  #MenuBarIcon_Myfamily_BackupDatabase
  #Image_Myfamily_Kill
EndEnumeration

#ImageIndex  =  #PB_Compiler_EnumerationValue
Purevision does the above. Note that it ends each enumeration with the current state such as

Code: Select all

#WindowIndex = #PB_Compiler_EnumerationValue
for the windows value.

So if you have more of your own window enumerations, just start your section off with:

Code: Select all

Enumeration #WindowIndex 
and the window enumeration will be then correct.
Fangbeast!!!!!!!!!!!!!! How are you?

I figured you would chime in. Thank you for your input!

I am slowly creating my own screens etc on the fly so this will be very handy! Thank You!

Sent from my SM-G955U using Tapatalk

Re: PopUp Menus

Posted: Tue Dec 31, 2019 5:58 am
by Paul
Fangbeast is correct, you could do something like this...

Code: Select all

Enumeration #WindowIndex
  #MyPopUpMenu
  #MyPopUpMenu1
  #MyPopUpMenu2
EndEnumeration

Enumeration #GadgetIndex
  #PopupMenu_ViewEdit
  #PopupMenu_Delete
  #PopupMenu_Duplicate
  #PopupMenu_Cancel

  #PopupMenu1_ViewEdit
  #PopupMenu1_Cancel

  #PopupMenu2_ViewEdit
  #PopupMenu2_Cancel
EndEnumeration

Re: PopUp Menus

Posted: Tue Dec 31, 2019 6:45 am
by deanathpc
Paul wrote:Fangbeast is correct, you could do something like this...

Code: Select all

Enumeration #WindowIndex
  #MyPopUpMenu
  #MyPopUpMenu1
  #MyPopUpMenu2
EndEnumeration

Enumeration #GadgetIndex
  #PopupMenu_ViewEdit
  #PopupMenu_Delete
  #PopupMenu_Duplicate
  #PopupMenu_Cancel

  #PopupMenu1_ViewEdit
  #PopupMenu1_Cancel

  #PopupMenu2_ViewEdit
  #PopupMenu2_Cancel
EndEnumeration
Nice! So, clearly, there are a few ways to do this.

Thanks!

Sent from my SM-G955U using Tapatalk

Re: PopUp Menus

Posted: Tue Dec 31, 2019 7:31 am
by Fangbeast
I am fine Sir Dean!!! Trying not to let the Aussie heat burn me to a Sir Crispie!!

Sir Paul of PV provided many means for us mere mortals to do wonderful things if we had but the wit to use them (Sometimes I even do!!).

13 years of PV here (I think). Can still do lots of wonderful things with it:):) (Paul, hope I haven't swelled your head to much hehehehehe)

When Paul is too cold to chime in, you can always send me messages:):)

Re: PopUp Menus

Posted: Tue Dec 31, 2019 9:10 am
by deanathpc
Fangbeast wrote:I am fine Sir Dean!!! Trying not to let the Aussie heat burn me to a Sir Crispie!!

Sir Paul of PV provided many means for us mere mortals to do wonderful things if we had but the wit to use them (Sometimes I even do!!).

13 years of PV here (I think). Can still do lots of wonderful things with it:):) (Paul, hope I haven't swelled your head to much hehehehehe)

When Paul is too cold to chime in, you can always send me messages:):)
Ha ha! That is awesome! Glad to hear it. But I will gladly trade you this weather I have for yours! Any day! :)

I keep looking at code from everyone else and just amazes me the 10 different ways to accomplish the same thing. You folks are way more advanced than I here so every once in awhile I have to reach out and ask for help. This current software I am writing I have crawled out of my comfort zone and have started doing more with Pure Basic than ever before. Realize some mistakes I've made and how much I have not followed the work smarter not harder rule I try to follow. lol

O.K. Back to looking at your example and attempt to wrap my brain around it. I know have a working Popup Menu but the more I learn the cleaner my code will get. Or so I hope!

Stay frosty!