It is currently Sun Jan 17, 2021 5:49 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 47 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
 Post subject: Re: COCOA quests?
PostPosted: Wed Aug 26, 2020 3:24 pm 
Offline
Addict
Addict

Joined: Mon Nov 25, 2013 6:41 am
Posts: 843
Shardik wrote:
If mestnyi wants to get rid of PureBasic's event loop, he might try a permanent run loop:

Yes, this is what I need.
Only I need a loop, not a function call.
Code:
Procedure WindowCloseEvent()
  CloseWindow(EventWindow())
; End
EndProcedure

OpenWindow(0, 270, 100, 250, 100, "Permanent loop demo")
BindEvent(#PB_Event_CloseWindow, @WindowCloseEvent(), 0)

CocoaMessage(0, CocoaMessage(0, 0, "NSApplication sharedApplication"), "run")
Debug "close include window"

OpenWindow(10, 270, 100, 250, 100, "Permanent")
BindEvent(#PB_Event_CloseWindow, @WindowCloseEvent(), 10)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow


Top
 Profile  
Reply with quote  
 Post subject: Re: COCOA quests?
PostPosted: Wed Nov 18, 2020 4:08 pm 
Offline
Addict
Addict

Joined: Mon Nov 25, 2013 6:41 am
Posts: 843
Can anyone help me implement this?
Code:
Global message_window
Global message_event
Global message_ok
Global message_no

Procedure message_events()
  Select EventType()
    Case #PB_EventType_LeftClick
      Select EventGadget()
        Case message_ok : message_event = #PB_MessageRequester_Yes
        Case message_no : message_event = #PB_MessageRequester_No
      EndSelect
     
      CloseWindow(EventWindow())
  EndSelect
EndProcedure

Procedure message(text.s)
  Protected UseGadgetList = UseGadgetList(0)
  Protected window = OpenWindow(#PB_Any, 270, 100, 260, 100, text, #PB_Window_TitleBar|#PB_Window_WindowCentered)
  message_ok = ButtonGadget( #PB_Any, 10,60, 120,30,"Ok")
  message_no = ButtonGadget( #PB_Any, 130,60, 120,30,"No")
  BindGadgetEvent(message_ok, @message_events())
  BindGadgetEvent(message_no, @message_events())
  StickyWindow( window, 1 )
  UseGadgetList(UseGadgetList)
 
  Debug "open"
  CocoaMessage(0, CocoaMessage(0, 0, "NSApplication sharedApplication"), "run")
  Debug "close"
 
  ProcedureReturn message_event
EndProcedure

Procedure button_events()
  Select EventType()
    Case #PB_EventType_LeftClick
      If Message("message") = #PB_MessageRequester_Yes
        Debug "Yes"
      Else
        Debug "No"
      EndIf
     
  EndSelect
EndProcedure

OpenWindow(10, 270, 100, 300, 300, "main window", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)

If Message("message") = #PB_MessageRequester_Yes
  Debug "good"
Else
  Debug "end"
  End
EndIf

ButtonGadget( 1, 10,10, 120,30,"custom message")
BindGadgetEvent(1, @button_events())

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 47 posts ]  Go to page Previous  1, 2, 3, 4

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye