#PB_Any support for AddKeyboardShortcut()!

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> if i create multiple shourtcuts with the same MenuID they override the old ones

You could always use Enumeration so no two MenuIDs will ever be the same.

> #PB_Any is NEEDED

Not needed, but maybe highly desirable. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Dummy
Enthusiast
Enthusiast
Posts: 162
Joined: Wed Jun 09, 2004 11:10 am
Location: Germany
Contact:

Post by Dummy »

Whisper() is a linked list containing all whisper(=privatechat)windows


Windows creation:

Code: Select all

      If found = 0
        AddElement(Whisper())
        Whisper()\Partner = p
        Whisper()\Window  = OpenWindow(#PB_Any, 0, 0, 100, 100, #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_SystemMenu, "Whisper to "+Whisper()\Partner)
        If CreateGadgetList(WindowID()) = 0
          Error("Could not open Window!")
        EndIf
        Whisper()\History = EditorGadget(#PB_Any, 0, 0, 100, 80)
        Whisper()\NewMsg  = StringGadget(#PB_Any, 0, 80, 100, 20, "")
        Whisper()\Menu    = AddKeyboardShortcut(Whisper()\Window, #PB_Shortcut_Return, #PB_Any)
      EndIf
      SetGadgetText(Whisper()\NewMsg, text)
Event Check:

Code: Select all

      ForEach Whisper()
        If Whisper()\Menu = event
          String = GetGadgetText(Whisper()\NewMsg)
          AddGadgetItem(Whisper()\History, -1, User+":"+String)
          String = "/w "+Whisper()\Partner+" "+String
          If Len(String) > 4090
            Packet_Size(Len(String)+6)
          EndIf
          Packet_New(#nMsg_ChatMsg)
          Packet_AddString(String)
          Packet_Send()
          SetGadgetText(Whisper()\NewMsg, "")
        EndIf
      Next
Now please give me the code to obtain free MenuIDs for the Shortcuts!
-Since there is no GetFreeMenuID() command that doesnt work
-#PB_any is not supported und u don't want it to
-Constants cant be used as the count of whisperwindows variies
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

Dummy wrote: Maybe this'll work??
Windows creation:

Code: Select all

 ; ...
        Whisper()\History = EditorGadget(#PB_Any, 0, 0, 100, 80)
        Whisper()\NewMsg  = StringGadget(#PB_Any, 0, 80, 100, 20, "")
        Whisper()\Menu    =  Whisper()\Window
        AddKeyboardShortcut(Whisper()\Window, #PB_Shortcut_Return, Whisper()\Window)
 , ...
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

Why does it need to be changed? You can just get EventWindowID() and figure out which window it was used on.
~I see one problem with your reasoning: the fact is thats not a chicken~
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> You can just get EventWindowID() and figure out which window it was used on

Exactly! Each AddKeyboardShortcut can then have the same MenuID, without
the need to worry about it clashing with any other MenuIDs.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Dummy
Enthusiast
Enthusiast
Posts: 162
Joined: Wed Jun 09, 2004 11:10 am
Location: Germany
Contact:

Post by Dummy »

PB wrote:> You can just get EventWindowID() and figure out which window it was used on

Exactly! Each AddKeyboardShortcut can then have the same MenuID, without
the need to worry about it clashing with any other MenuIDs.
ever tried that?
Maybe this'll work??
Windows creation:
Code:

; ...
Whisper()\History = EditorGadget(#PB_Any, 0, 0, 100, 80)
Whisper()\NewMsg = StringGadget(#PB_Any, 0, 80, 100, 20, "")
Whisper()\Menu = Whisper()\Window
AddKeyboardShortcut(Whisper()\Window, #PB_Shortcut_Return, Whisper()\Window)
, ...
hmmm but that dirty code

can couze bugs

i dont like buggy programs
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> ever tried that?

Oops, my mistake. I think I'll keep out of this for now. :oops:
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Post Reply